first running version of perl-bindings
authorStefan Haas <shaas@suse.de>
Thu, 6 Sep 2007 14:15:14 +0000 (14:15 +0000)
committerStefan Haas <shaas@suse.de>
Thu, 6 Sep 2007 14:15:14 +0000 (14:15 +0000)
swig/CMakeLists.txt
swig/ItemCapKind.i [new file with mode: 0644]
swig/RepoInfo.i
swig/ResPool.i
swig/ResStatus.i
swig/Resolver.i [new file with mode: 0644]
swig/perl5/CMakeLists.txt [new file with mode: 0644]
swig/perl5/perl.i [new file with mode: 0644]
swig/zypp.i

index b3004d4..8cac9d9 100644 (file)
@@ -3,3 +3,5 @@ ADD_SUBDIRECTORY(ruby)
 
 ADD_SUBDIRECTORY(python)
 
+ADD_SUBDIRECTORY(perl5)
+
diff --git a/swig/ItemCapKind.i b/swig/ItemCapKind.i
new file mode 100644 (file)
index 0000000..6493130
--- /dev/null
@@ -0,0 +1,59 @@
+/*%{
+
+struct solver::detail::ItemCapKind
+{
+       public:
+       Capability cap; //Capability which has triggerd this selection
+       Dep capKind; //Kind of that capability
+       PoolItem_Ref item; //Item which has triggered this selection
+       bool initialInstallation; //This item has triggered the installation
+                                 //Not already fullfilled requierement only.
+
+       ItemCapKind( PoolItem i, Capability c, Dep k, bool initial)
+               : cap( c )
+               , capKind( k )
+               , item( i )
+               , initialInstallation( initial )
+           { }
+};
+//typedef std::list<solver::detail::ItemCapKind> solver::detail::ItemCapKindList;
+%}
+*/
+
+namespace zypp
+{
+   namespace solver
+   {
+      namespace detail
+      {
+
+         struct ItemCapKind
+         {
+         public:
+            Capability cap;
+            Dep capKind;
+            PoolItem_Ref item;
+            bool initialInstallation;
+
+            /*%extend { 
+               ItemCapKind(){};
+            }*/
+
+            //ItemCapKind();
+            ItemCapKind( PoolItem i, Capability c, Dep k, bool initial)
+               : cap( c )
+               , capKind( k )
+               , item( i )
+               , initialInstallation( initial )
+                { }
+         };
+      }
+   }
+}
+typedef std::list<solver::detail::ItemCapKind> solver::detail::ItemCapKindList;
+%template(ItemCapKindList) std::list<solver::detail::ItemCapKind>;
+
+#ifdef SWIGRUBY
+   auto_iterator(std::list<solver::detail::ItemCapKind>, solver::detail::ItemCapKind);
+#endif
+
index 0210642..afbd32a 100644 (file)
@@ -1,5 +1,7 @@
-
-%template(UrlSet) std::set<Url>;
+#ifdef SWIGPERL5
+#else
+   %template(UrlSet) std::set<Url>;
+#endif
 
 class RepoInfo
 {
index 998dc75..b288160 100644 (file)
@@ -27,10 +27,10 @@ class ResPool
 
     /** \name Iterate through all ResObjects (all kinds). */
     //@{
-    /**
+    #ifdef SWIGPERL5 
     const_iterator begin() const;
     const_iterator end() const;
-    */
+    #endif
     //@}
 
   public:
@@ -150,6 +150,27 @@ class ResPool
 
 };
 
+#ifdef SWIGPERL5
+
+%extend ResPool {
+
+   pool::PoolTraits::const_iterator iterator_incr(pool::PoolTraits::const_iterator *it ) {
+      (*it)++;
+      return *it;
+   }
+   pool::PoolTraits::const_iterator iterator_decr(pool::PoolTraits::const_iterator it) {
+      (it)--;
+      return it;
+   }
+   bool iterator_equal(pool::PoolTraits::const_iterator it1, pool::PoolTraits::const_iterator it2) {
+      return (it1 == it2);
+   }
+   PoolItem_Ref iterator_value(pool::PoolTraits::const_iterator it) {
+      return (*it);
+   }
+};
+
+#endif
 
 #ifdef SWIGRUBY
 
index a26056c..7661354 100644 (file)
@@ -1,6 +1,16 @@
 
 class ResStatus
 {
+  public:
+
+    /** Default ctor. */
+    ResStatus();
+
+    /** Ctor setting the initial . */
+    ResStatus( bool isInstalled_r );
+
+    /** Dtor. */
+    ~ResStatus();
 
   public:
     /** \name BitField range definitions.
@@ -78,9 +88,9 @@ class ResStatus
       };
     enum SolverStateValue
       {
-       NORMAL     = bit::RangeValue<SolverStateField,0>::value, // default, notthing special
-       SEEN       = bit::RangeValue<SolverStateField,1>::value, // already seen during ResolverUpgrade
-       IMPOSSIBLE = bit::RangeValue<SolverStateField,2>::value  // impossible to install
+         NORMAL     = bit::RangeValue<SolverStateField,0>::value, // default, notthing special
+         SEEN       = bit::RangeValue<SolverStateField,1>::value, // already seen during ResolverUpgrade
+         IMPOSSIBLE = bit::RangeValue<SolverStateField,2>::value        // impossible to install
       };
 
     enum LicenceConfirmedValue
@@ -92,15 +102,6 @@ class ResStatus
 
   public:
 
-    /** Default ctor. */
-    ResStatus();
-
-    /** Ctor setting the initial . */
-    ResStatus( bool isInstalled_r );
-
-    /** Dtor. */
-    ~ResStatus();
-
     /** Debug helper returning the bitfield.
      * It's save to expose the bitfield, as it can't be used to
      * recreate a ResStatus. So it is not possible to bypass
@@ -369,3 +370,14 @@ class ResStatus
   private:
     BitFieldType _bitfield;
 };
+
+#ifdef SWIGPERL5
+
+   %extend ResStatus {
+      
+      bool setToBeInstalledUser()
+      {   
+         return self->setToBeInstalled(ResStatus::USER);
+      }   
+   };
+#endif
diff --git a/swig/Resolver.i b/swig/Resolver.i
new file mode 100644 (file)
index 0000000..a83d6bc
--- /dev/null
@@ -0,0 +1,50 @@
+#ifdef SWIGPERL5
+   %template(StringList) std::list<std::string>;
+#endif
+
+class Resolver
+{
+   public:
+      Resolver( const ResPool & pool);
+      virtual ~Resolver();
+      bool verifySystem ();
+      bool verifySystem (bool considerNewHardware);
+      bool establishPool (void);
+      bool freshenPool (void);
+      bool resolvePool (void);      
+      bool resolvePool (bool tryAllPossibilities);
+      bool resolveDependencies( void );
+      void undo( void );
+      solver::detail::ResolverContext_Ptr context (void) const;
+      void doUpgrade( UpgradeStatistics & opt_stats_r );
+      std::list<PoolItem_Ref> problematicUpdateItems( void ) const;
+      ResolverProblemList problems();
+      std::list<std::string> problemDescription( void ) const;      
+      void applySolutions( const ProblemSolutionList & solutions );
+
+      Arch architecture() const;
+      void setArchitecture( const Arch & arch);
+      void setForceResolve (const bool force);
+      const bool forceResolve();
+      void setPreferHighestVersion (const bool highestVersion);
+      const bool preferHighestVersion();      
+      bool transactResObject( ResObject::constPtr robj, bool install = true);
+      //bool transactResKind( Resolvable::Kind kind );
+      void transactReset( ResStatus::TransactByValue causer );
+      void addRequire (const Capability & capability);
+      void addConflict (const Capability & capability);      
+      void setTimeout( int seconds );
+      int timeout();      
+      void setMaxSolverPasses (int count);
+      int maxSolverPasses ();
+      bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
+      const solver::detail::ItemCapKindList isInstalledBy (const PoolItem_Ref item);
+      const std::list<solver::detail::ItemCapKind> installs (const PoolItem_Ref item);
+      //const solver::detail::ItemCapKindList installs (const PoolItem_Ref item);
+
+  protected:
+
+  private:
+      solver::detail::Resolver_Ptr _pimpl;
+};
+
diff --git a/swig/perl5/CMakeLists.txt b/swig/perl5/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cfed831
--- /dev/null
@@ -0,0 +1,41 @@
+FIND_PACKAGE(Perl REQUIRED)
+
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{cppflags}" OUTPUT_VARIABLE PERL_CXX_FLAGS)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PERL_CXX_FLAGS}")
+
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{archlibexp}" OUTPUT_VARIABLE PERL_LIB_PATH)
+SET( PERL_INS_PATH "${PERL_LIB_PATH}" )
+SET( PERL_LIB_PATH "${PERL_LIB_PATH}/CORE" )
+
+MESSAGE(STATUS "Perl executable: ${PERL_EXECUTABLE}")
+MESSAGE(STATUS "Perl cpp-flags: ${PERL_CXX_FLAGS}")
+MESSAGE(STATUS "Perl lib path: ${PERL_LIB_PATH}")
+
+SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx" )
+SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/zypp.i" )
+
+ADD_CUSTOM_COMMAND (
+   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx
+   COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for perl..."
+   COMMAND ${SWIG_EXECUTABLE} -c++ -perl5 -xmlout ${CMAKE_CURRENT_BINARY_DIR}/parse.xml -o ${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx -I${ZYPP_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../zypp.i
+   COMMAND ${CMAKE_COMMAND} -E echo "Done."
+   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../*.i ${CMAKE_CURRENT_SOURCE_DIR}/*.i
+)
+
+ADD_CUSTOM_TARGET( glue
+   DEPENDS ${SWIG_OUTPUT}
+)
+
+ADD_LIBRARY( zypp SHARED "${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx" )
+SET_TARGET_PROPERTIES( zypp PROPERTIES PREFIX "" )
+ADD_DEPENDENCIES( zypp glue )
+
+INCLUDE_DIRECTORIES( ${PERL_LIB_PATH} )
+INCLUDE_DIRECTORIES( ${ZYPP_INCLUDE_DIR} )
+TARGET_LINK_LIBRARIES( zypp ${ZYPP_LIBRARY} )
+
+INSTALL(TARGETS zypp LIBRARY DESTINATION ${PERL_INS_PATH})
+INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/zypp.pm DESTINATION ${PERL_INS_PATH})
+
diff --git a/swig/perl5/perl.i b/swig/perl5/perl.i
new file mode 100644 (file)
index 0000000..e69de29
index fb88268..121d9a6 100644 (file)
@@ -1,11 +1,17 @@
 %module zypp
 
+#ifdef SWIGPERL5
+%{
+   #define SWIGPERLHACK
+   #undef NORMAL
+%}   
+#endif
+
 %{
 /* Includes the header in the wrapper code */
 #include "zypp/base/PtrTypes.h"
 #include <zypp/Edition.h>
 #include <zypp/ResTraits.h>
-#include <zypp/ResPoolProxy.h>
 #include <zypp/ResStore.h>
 #include <zypp/ZYppFactory.h>
 #include <zypp/ZYpp.h>
 #include "zypp/ResObject.h"
 #include "zypp/ResPoolManager.h"
 #include "zypp/Target.h"
-#include "zypp/target/TargetImpl.h"
+#ifndef SWIGPERLHACK
+   #include "zypp/target/TargetImpl.h"
+   #include "zypp/MediaSetAccess.h"
+#endif
 #include "zypp/TranslatedText.h"
 #include "zypp/CapFactory.h"
 #include "zypp/Package.h"
@@ -23,8 +32,8 @@
 #include "zypp/Repository.h"
 #include "zypp/RepoManager.h"
 #include "zypp/repo/RepoType.h"
-#include "zypp/MediaSetAccess.h"
 #include "zypp/TmpPath.h"
+#include "zypp/Resolver.h"
 
 using namespace boost;
 using namespace zypp;
@@ -33,6 +42,7 @@ using namespace zypp::resfilter;
 using namespace zypp::filesystem;
 
 typedef std::set<Url> UrlSet;
+typedef std::list<std::string> StringList;
 %}
 
 %rename("+") "operator+";
@@ -65,9 +75,13 @@ class intrusive_ptr {
 %include "python/python.i"
 #endif
 
+#ifdef SWIGPERL5
+%include "std_list.i"
+#endif
 
 %include "Pathname.i"
 %include "Url.i"
+%include "ResStatus.i"
 %include "NeedAType.i"
 %include "Arch.i"
 %include "ResStore.i"
@@ -96,15 +110,18 @@ class intrusive_ptr {
 %include "Package.i"
 %include "PublicKey.i"
 %include "KeyRing.i"
-%include "Target.i"
-%include "ResStatus.i"
+#ifndef SWIGPERL5
+   %include "Target.i"
+   %include "MediaSetAccess.i"
+#endif
 %include "PoolItem.i"
 %include "ResPool.i"
 %include "ResPoolManager.i"
 %include "ZYppCommitPolicy.i"
 %include "ZYppCommitResult.i"
-%include "MediaSetAccess.i"
 %include "TmpPath.i"
+%include "Resolver.i"
+%include "ItemCapKind.i"
 
 
 class ZYpp