Skip to content

Commit

Permalink
Enable AdvisoryModule bindings
Browse files Browse the repository at this point in the history
There is a problem in Perl with namespace conflicts. Undefine
`get_context` to fix the issue.

More general solution would be to use `PERL_NO_SHORT_NAMES` it would fix
other potential conflicts however it doesn't compile with it.

Some more information is in: https://www.swig.org/Doc4.1/SWIGDocumentation.html#Perl5_nn9
  • Loading branch information
kontura committed Oct 24, 2023
1 parent 5063592 commit 2a11a03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bindings/libdnf5/advisory.i
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
}
}

// TODO(jkolarik): advisory modules skipped for now

%{
#include "libdnf5/advisory/advisory.hpp"
#include "libdnf5/advisory/advisory_package.hpp"
#include "libdnf5/advisory/advisory_module.hpp"
#include "libdnf5/advisory/advisory_set.hpp"
#include "libdnf5/advisory/advisory_set_iterator.hpp"
#include "libdnf5/advisory/advisory_collection.hpp"
Expand All @@ -47,11 +46,12 @@
%rename(value) libdnf5::advisory::AdvisorySetIterator::operator*();
%include "libdnf5/advisory/advisory_set_iterator.hpp"

%ignore libdnf5::advisory::AdvisoryCollection::get_modules();
%include "libdnf5/advisory/advisory_module.hpp"
%include "libdnf5/advisory/advisory_collection.hpp"
%include "libdnf5/advisory/advisory_query.hpp"
%include "libdnf5/advisory/advisory_reference.hpp"

%template(VectorAdvisoryModule) std::vector<libdnf5::advisory::AdvisoryModule>;
%template(VectorAdvisoryCollection) std::vector<libdnf5::advisory::AdvisoryCollection>;
%template(VectorAdvisoryPackage) std::vector<libdnf5::advisory::AdvisoryPackage>;
%template(VectorAdvisoryReference) std::vector<libdnf5::advisory::AdvisoryReference>;
Expand Down
8 changes: 8 additions & 0 deletions bindings/libdnf5/shared.i
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@

// From perl5 - utf8.h: conflicts with fmt/format.h header
#undef utf8_to_utf16

// Recent versions of Perl (5.8.0) have namespace conflict problems.
// Perl defines a bunch of short macros to make the Perl API function names shorter.
// For example, in /usr/lib64/perl5/CORE/embed.h there is:
// #define get_context Perl_get_context
// We have to undefine that since we don't want our AdvisoryModule::get_context to
// be renamed to Perl_get_context
#undef get_context
%}

0 comments on commit 2a11a03

Please sign in to comment.