Minor binding fix to work with nullptr

This commit is contained in:
Сергей Конев 2024-10-25 14:51:16 +03:00
parent 07f8a400f2
commit c8a0505ff7

View File

@ -589,9 +589,20 @@ const char *pkg_file_iter_file_name(PPkgFileIterator *wrapper) {
return wrapper->iterator.FileName();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_archive(PPkgFileIterator *wrapper) {
return wrapper->iterator.Archive();
}
#else
const char *pkg_file_iter_archive(PPkgFileIterator *wrapper) {
const char *archive = wrapper->iterator.Archive();
if (archive == nullptr) {
// Should be non-null
return to_c_string("Not Specified");
}
return archive;
}
#endif
const char *pkg_file_iter_version(PPkgFileIterator *wrapper) {
return wrapper->iterator.Version();
@ -624,14 +635,37 @@ const char *pkg_file_iter_site(PPkgFileIterator *wrapper) {
return wrapper->iterator.Site();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_component(PPkgFileIterator *wrapper) {
return wrapper->iterator.Component();
}
#else
const char *pkg_file_iter_component(PPkgFileIterator *wrapper) {
const char *component = wrapper->iterator.Component();
if (component == nullptr) {
// Should be non-null
return to_c_string("Not Specified");
}
return component;
}
#endif
const char *pkg_file_iter_architecture(PPkgFileIterator *wrapper) {
return wrapper->iterator.Architecture();
}
#ifndef ALT_LINUX
const char *pkg_file_iter_index_type(PPkgFileIterator *wrapper) {
return wrapper->iterator.IndexType();
}
#else
const char *pkg_file_iter_index_type(PPkgFileIterator *wrapper) {
const char *index_type = wrapper->iterator.IndexType();
if (index_type == nullptr) {
// Should be non-null
return to_c_string("Not Specified");
}
return index_type;
}
#endif