From a928dba502776e7561b2de7a3ab606f68e31de07 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 21 May 2020 17:45:43 +0200 Subject: [PATCH] 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. --- src/bindings/luajit/eina/accessor.lua | 6 +- src/bindings/luajit/eina/counter.lua | 2 +- src/bindings/luajit/eina/file.lua | 6 +- src/bindings/luajit/eina/iterator.lua | 4 +- src/bindings/luajit/eina/list.lua | 46 ++++--- src/bindings/luajit/eina/xattr.lua | 4 +- src/bindings/luajit/eo.lua | 6 +- src/bindings/luajit/eolian.lua | 176 +++++++++++++------------- 8 files changed, 128 insertions(+), 122 deletions(-) diff --git a/src/bindings/luajit/eina/accessor.lua b/src/bindings/luajit/eina/accessor.lua index 55afa62427..d2068fc8b5 100644 --- a/src/bindings/luajit/eina/accessor.lua +++ b/src/bindings/luajit/eina/accessor.lua @@ -46,12 +46,12 @@ ffi.metatype("Eina_Accessor", { unlock = function(self) return eina.eina_accessor_unlock(self) ~= 0 end, clone = function(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 end, container_get = function(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 end } @@ -64,7 +64,7 @@ local dgetmt = debug.getmetatable M.Accessor = util.Readonly_Object:clone { __ctor = function(self, selfmt, acc) -- 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 selfmt.__eq = function(self, other) return selfmt.__accessor == dgetmt(other).__accessor diff --git a/src/bindings/luajit/eina/counter.lua b/src/bindings/luajit/eina/counter.lua index b0b9829ad4..6a9ba33284 100644 --- a/src/bindings/luajit/eina/counter.lua +++ b/src/bindings/luajit/eina/counter.lua @@ -51,7 +51,7 @@ M.Counter = ffi.metatype("Eina_Counter", { dump = function(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) C.free(v) return r diff --git a/src/bindings/luajit/eina/file.lua b/src/bindings/luajit/eina/file.lua index 675b810a17..3f59391b60 100644 --- a/src/bindings/luajit/eina/file.lua +++ b/src/bindings/luajit/eina/file.lua @@ -236,7 +236,7 @@ M.direct_ls = function(dir) return Direct_Ls_Iterator(dir) end M.path_sanitize = function(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) C.free(v) return r @@ -358,7 +358,7 @@ M.File = ffi.metatype("Eina_File", { map_all = function(self, rule, raw) 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 local r = ffi.string(v) self:map_free(v) @@ -370,7 +370,7 @@ M.File = ffi.metatype("Eina_File", { map_new = function(self, rule, offset, length, raw) local v = ffi.cast("char*", eina.eina_file_map_new(self, rule or 0, offset or 0, length)) - if v == nil then return nil end + if v == ffi.nullptr then return nil end if not raw then local r = ffi.string(v, length) self:map_free(v) diff --git a/src/bindings/luajit/eina/iterator.lua b/src/bindings/luajit/eina/iterator.lua index dc5d0da8b2..196a968500 100644 --- a/src/bindings/luajit/eina/iterator.lua +++ b/src/bindings/luajit/eina/iterator.lua @@ -43,7 +43,7 @@ ffi.metatype("Eina_Iterator", { unlock = function(self) return eina.eina_iterator_unlock(self) ~= 0 end, container_get = function(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 end } @@ -56,7 +56,7 @@ local dgetmt = debug.getmetatable M.Iterator = util.Readonly_Object:clone { __ctor = function(self, selfmt, iter) -- 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 selfmt.__eq = function(self, other) return selfmt.__iterator == dgetmt(other).__iterator diff --git a/src/bindings/luajit/eina/list.lua b/src/bindings/luajit/eina/list.lua index aebfa348c1..4c0bc6bd17 100644 --- a/src/bindings/luajit/eina/list.lua +++ b/src/bindings/luajit/eina/list.lua @@ -83,7 +83,9 @@ local dgetmt = debug.getmetatable local List_Iterator = Iterator:clone { __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 return Iterator.__ctor(self, selfmt, eina.eina_list_iterator_new(dgetmt(list).__list)) @@ -98,7 +100,9 @@ local List_Iterator = Iterator:clone { local List_Reverse_Iterator = Iterator:clone { __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 return Iterator.__ctor(self, selfmt, eina.eina_list_iterator_reversed_new(dgetmt(list).__list)) @@ -115,7 +119,9 @@ local Accessor = accessor.Accessor local List_Accessor = Accessor:clone { __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 return Accessor.__ctor(self, selfmt, eina.eina_list_accessor_new(dgetmt(list).__list)) @@ -141,37 +147,37 @@ local List = ffi.metatype("Eina_List", { data_get = function(self, ptr) if ptr ~= nil then return ptr end local v = get_list_t(self).data - if v == nil then return nil end + if v == ffi.nullptr then return nil end return v end, nth = function(self, n) 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) end, nth_list = function(self, n) 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 end, last = function(self) 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 end, next = function(self) local v = get_list_t(self).next - if v == nil then return nil end + if v == ffi.nullptr then return nil end return v end, prev = function(self) local v = get_list_t(self).prev - if v == nil then return nil end + if v == ffi.nullptr then return nil end return v end } @@ -183,7 +189,7 @@ local List_Base = util.Readonly_Object:clone { list = ffi.gc(list, freefunc) selfmt.__free = freefunc end - if list == nil then return end + if not list or list == ffi.nullptr then return end selfmt.__eq = function(self, other) return selfmt.__list == dgetmt(other).__list end @@ -194,62 +200,62 @@ local List_Base = util.Readonly_Object:clone { free = function(self) self = dgetmt(self) 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)) end, count = function(self) self = dgetmt(self) local l = self.__list - if l == nil then return 0 end + if not l or l == ffi.nullptr then return 0 end return #l end, nth = function(self, n) self = dgetmt(self) 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() end, nth_list = function(self, n) self = dgetmt(self) 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()) end, last = function(self, n) self = dgetmt(self) 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()) end, next = function(self, n) self = dgetmt(self) 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()) end, prev = function(self, n) self = dgetmt(self) 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()) end, data_get = function(self, ptr) self = dgetmt(self) 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) end, to_array = function(self) 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 r = {} while l ~= nil do @@ -293,7 +299,7 @@ M.Ptr_List = List_Base:clone { M.String_List = List_Base:clone { data_get = function(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) end } diff --git a/src/bindings/luajit/eina/xattr.lua b/src/bindings/luajit/eina/xattr.lua index 192d39b85f..3e2417d194 100644 --- a/src/bindings/luajit/eina/xattr.lua +++ b/src/bindings/luajit/eina/xattr.lua @@ -98,7 +98,7 @@ end M.get = function(file, attribute) local size = ffi.new("size_t[1]") 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]) C.free(v) return r @@ -126,7 +126,7 @@ end M.string_get = function(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) C.free(v) return r diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua index bebe733853..42531aa153 100644 --- a/src/bindings/luajit/eo.lua +++ b/src/bindings/luajit/eo.lua @@ -337,7 +337,7 @@ end local get_obj_mt = function(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)] end @@ -416,7 +416,7 @@ ffi.metatype("Eo", { -- handles property getting with no keys and also properties with keys __index = function(self, key) 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 pp = pt[key] if not pp then @@ -444,7 +444,7 @@ ffi.metatype("Eo", { -- handles property setting with no keys __newindex = function(self, key, val) 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 pp = pt[key] if not pp then diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index 93499df6a5..7bd8f96894 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -556,7 +556,7 @@ local object_idx, wrap_object = gen_wrap { unit_get = function(self) local v = eolian.eolian_object_unit_get(cast_obj(self)) - if v == nil then + if v == ffi.nullptr then return nil end return v @@ -572,7 +572,7 @@ local object_idx, wrap_object = gen_wrap { file_get = function(self) local v = eolian.eolian_object_file_get(cast_obj(self)) - if v == nil then + if v == ffi.nullptr then return nil end return ffi.string(v) @@ -580,7 +580,7 @@ local object_idx, wrap_object = gen_wrap { name_get = function(self) local v = eolian.eolian_object_name_get(cast_obj(self)) - if v == nil then + if v == ffi.nullptr then return nil end return ffi.string(v) @@ -588,7 +588,7 @@ local object_idx, wrap_object = gen_wrap { c_name_get = function(self) local v = eolian.eolian_object_c_name_get(cast_obj(self)) - if v == nil then + if v == ffi.nullptr then return nil end return ffi.string(v) @@ -596,7 +596,7 @@ local object_idx, wrap_object = gen_wrap { short_name_get = function(self) local v = eolian.eolian_object_short_name_get(cast_obj(self)) - if v == nil then + if v == ffi.nullptr then return nil end return ffi.string(v) @@ -617,7 +617,7 @@ ffi.metatype("Eolian_Object", { __index = object_idx }) local unit_idx, wrap_unit = gen_wrap { state_get = function(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 end, @@ -628,13 +628,13 @@ local unit_idx, wrap_unit = gen_wrap { file_get = function(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) end, file_path_get = function(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) end, @@ -644,7 +644,7 @@ local unit_idx, wrap_unit = gen_wrap { object_by_name_get = function(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 end, @@ -655,7 +655,7 @@ local unit_idx, wrap_unit = gen_wrap { class_by_name_get = function(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 end, @@ -666,13 +666,13 @@ local unit_idx, wrap_unit = gen_wrap { constant_by_name_get = function(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 end, error_by_name_get = function(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 end, @@ -688,19 +688,19 @@ local unit_idx, wrap_unit = gen_wrap { alias_by_name_get = function(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 end, struct_by_name_get = function(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 end, enum_by_name_get = function(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 end, @@ -769,7 +769,7 @@ ffi.metatype("Eolian_State", { file_parse = function(self, fname) local v = eolian.eolian_state_file_parse(self, fname) - if v == nil then + if v == ffi.nullptr then return nil end return v @@ -777,7 +777,7 @@ ffi.metatype("Eolian_State", { file_path_parse = function(self, fpath) local v = eolian.eolian_state_file_path_parse(self, fpath) - if v == nil then + if v == ffi.nullptr then return nil end return v @@ -817,7 +817,7 @@ ffi.metatype("Eolian_State", { unit_by_file_get = function(self, fname) local v = eolian.eolian_state_unit_by_file_get(state, fname) - if v == nil then + if v == ffi.nullptr then return nil end return v @@ -835,7 +835,7 @@ ffi.metatype("Eolian_State", { class_by_file_get = function(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 end, @@ -961,13 +961,13 @@ ffi.metatype("Eolian_Struct_Type_Field", { __index = wrap_object { documentation_get = function(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 end, type_get = function(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 end, @@ -985,19 +985,19 @@ ffi.metatype("Eolian_Enum_Type_Field", { __index = wrap_object { c_name_get = function(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) end, documentation_get = function(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 end, value_get = function(self, force) 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 end } @@ -1016,7 +1016,7 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", { struct_field_get = function(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 end, @@ -1027,31 +1027,31 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", { enum_field_get = function(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 end, enum_legacy_prefix_get = function(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) end, documentation_get = function(self, name) 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 end, base_type_get = function(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 end, aliased_base_get = function(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 end, @@ -1061,19 +1061,19 @@ M.Typedecl = ffi.metatype("Eolian_Typedecl", { c_type_get = function(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) end, free_func_get = function(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) end, function_pointer_get = function(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 end } @@ -1091,37 +1091,37 @@ M.Type = ffi.metatype("Eolian_Type", { base_type_get = function(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 end, next_type_get = function(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 end, typedecl_get = function(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 end, aliased_base_get = function(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 end, class_get = function(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 end, error_get = function(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 end, @@ -1139,7 +1139,7 @@ M.Type = ffi.metatype("Eolian_Type", { c_type_get = function(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) end } @@ -1166,13 +1166,13 @@ M.Function = ffi.metatype("Eolian_Function", { full_c_name_get = function(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) end, implement_get = function(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 end, @@ -1205,19 +1205,19 @@ M.Function = ffi.metatype("Eolian_Function", { return_type_get = function(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 end, return_default_value_get = function(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 end, return_documentation_get = function(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 end, @@ -1240,7 +1240,7 @@ M.Function = ffi.metatype("Eolian_Function", { class_get = function(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 end } @@ -1261,19 +1261,19 @@ ffi.metatype("Eolian_Function_Parameter", { type_get = function(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 end, default_value_get = function(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 end, documentation_get = function(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 end, @@ -1295,26 +1295,26 @@ ffi.metatype("Eolian_Implement", { __index = wrap_object { class_get = function(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 end, implementing_class_get = function(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 end, function_get = function(self) local tp = ffi.new("Eolian_Function_Type[1]") 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] end, documentation_get = function(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 end, @@ -1344,13 +1344,13 @@ ffi.metatype("Eolian_Constructor", { __index = wrap_object { class_get = function(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 end, function_get = function(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 end, @@ -1364,19 +1364,19 @@ ffi.metatype("Eolian_Event", { __index = wrap_object { type_get = function(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 end, class_get = function(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 end, documentation_get = function(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 end, @@ -1386,7 +1386,7 @@ ffi.metatype("Eolian_Event", { c_macro_get = function(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) end, @@ -1404,13 +1404,13 @@ ffi.metatype("Eolian_Part", { __index = wrap_object { class_get = function(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 end, documentation_get = function(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 end } @@ -1432,13 +1432,13 @@ M.Class = ffi.metatype("Eolian_Class", { documentation_get = function(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 end, c_prefix_get = function(self) local v = eolian.eolian_class_c_prefix_get(self) - if v == nil then + if v == ffi.nullptr then local buf = self:namespaces_get() buf[#buf + 1] = self:short_name_get() return table.concat(buf, "_"):lower() @@ -1448,7 +1448,7 @@ M.Class = ffi.metatype("Eolian_Class", { event_c_prefix_get = function(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() end return ffi.string(v) @@ -1456,13 +1456,13 @@ M.Class = ffi.metatype("Eolian_Class", { data_type_get = function(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) end, parent_get = function(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 end, @@ -1484,7 +1484,7 @@ M.Class = ffi.metatype("Eolian_Class", { function_by_name_get = function(self, fname, ftype) local v = eolian.eolian_class_function_by_name_get(self, fname, ftype) - if v == nil then return nil end + if v == ffi.nullptr then return nil end return v end, @@ -1505,7 +1505,7 @@ M.Class = ffi.metatype("Eolian_Class", { event_by_name_get = function(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 end, @@ -1524,19 +1524,19 @@ M.Class = ffi.metatype("Eolian_Class", { c_get_function_name_get = function(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) end, c_macro_get = function(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) end, c_data_type_get = function(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) end } @@ -1611,7 +1611,7 @@ M.Value = ffi.metatype("Eolian_Value", { to_literal = function(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) end } @@ -1658,13 +1658,13 @@ M.Expression = ffi.metatype("Eolian_Expression", { eval = function(self, mask) mask = mask or emask.ALL 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) end, serialize = function(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) end, @@ -1678,13 +1678,13 @@ M.Expression = ffi.metatype("Eolian_Expression", { binary_lhs_get = function(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 end, binary_rhs_get = function(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 end, @@ -1694,13 +1694,13 @@ M.Expression = ffi.metatype("Eolian_Expression", { unary_expression_get = function(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 end, value_get = function(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) end } @@ -1710,19 +1710,19 @@ M.Constant = ffi.metatype("Eolian_Constant", { __index = wrap_object { documentation_get = function(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 end, type_get = function(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 end, value_get = function(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 end, @@ -1736,13 +1736,13 @@ M.Error = ffi.metatype("Eolian_Error", { __index = wrap_object { documentation_get = function(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 end, message_get = function(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) end, @@ -1756,19 +1756,19 @@ M.Documentation = ffi.metatype("Eolian_Documentation", { __index = wrap_object { summary_get = function(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) end, description_get = function(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) end, since_get = function(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) end } @@ -1807,7 +1807,7 @@ end M.documentation_tokenize = function(doc, ret) local ret = eolian.eolian_documentation_tokenize(doc, ret) - if ret == nil then + if ret == ffi.nullptr then return nil end return ffi.string(ret) @@ -1827,7 +1827,7 @@ M.Eolian_Doc_Token = ffi.metatype("Eolian_Doc_Token", { text_get = function(self) local str = eolian.eolian_doc_token_text_get(self) - if str == nil then + if str == ffi.nullptr then return nil end local ret = ffi.string(str)