Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7651 - in /trunk/sat-solver: bindings/ruby/CMakeLists.txt bindings/ruby/satsolver.rb bindings/satsolver.i src/pool.c src/pool.h
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Fri, 26 Oct 2007 13:57:13 -0000
  • Message-id: <20071026135714.0173217367@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Fri Oct 26 15:57:13 2007
New Revision: 7651

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7651&view=rev
Log:
each_solvable in Source almost working

Modified:
trunk/sat-solver/bindings/ruby/CMakeLists.txt
trunk/sat-solver/bindings/ruby/satsolver.rb
trunk/sat-solver/bindings/satsolver.i
trunk/sat-solver/src/pool.c
trunk/sat-solver/src/pool.h

Modified: trunk/sat-solver/bindings/ruby/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/CMakeLists.txt?rev=7651&r1=7650&r2=7651&view=diff
==============================================================================
--- trunk/sat-solver/bindings/ruby/CMakeLists.txt (original)
+++ trunk/sat-solver/bindings/ruby/CMakeLists.txt Fri Oct 26 15:57:13 2007
@@ -9,13 +9,13 @@
MESSAGE(STATUS "Ruby vendor arch dir: ${RUBY_VENDOR_ARCH_DIR}")
MESSAGE(STATUS "Ruby include path: ${RUBY_INCLUDE_PATH}")

-SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.c" )
+SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.cxx" )
SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/satsolver.i" )

ADD_CUSTOM_COMMAND (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.c
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.cxx
COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for ruby..."
- COMMAND ${SWIG_EXECUTABLE} -ruby -autorename -xmlout
${CMAKE_CURRENT_BINARY_DIR}/parse.xml -o
${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.c -I${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/../satsolver.i
+ COMMAND ${SWIG_EXECUTABLE} -c++ -ruby -autorename -xmlout
${CMAKE_CURRENT_BINARY_DIR}/parse.xml -o
${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.cxx -I${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/../satsolver.i
COMMAND ${CMAKE_COMMAND} -E echo "Done."
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../*.i ${CMAKE_CURRENT_SOURCE_DIR}/*.i
@@ -25,7 +25,7 @@
DEPENDS ${SWIG_OUTPUT}
)

-ADD_LIBRARY( satsolverx SHARED
"${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.c" )
+ADD_LIBRARY( satsolverx SHARED
"${CMAKE_CURRENT_BINARY_DIR}/libsatsolver_wrap.cxx" )
SET_TARGET_PROPERTIES( satsolverx PROPERTIES PREFIX "" )
ADD_DEPENDENCIES( satsolverx glue )


Modified: trunk/sat-solver/bindings/ruby/satsolver.rb
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/satsolver.rb?rev=7651&r1=7650&r2=7651&view=diff
==============================================================================
--- trunk/sat-solver/bindings/ruby/satsolver.rb (original)
+++ trunk/sat-solver/bindings/ruby/satsolver.rb Fri Oct 26 15:57:13 2007
@@ -2,11 +2,4 @@

module Satsolver
include Satsolverx
-
- class Pool
- def addsource_solv( fp, s);
- pool_addsource_solv(self, fp, s);
- end
- end
-
end
\ No newline at end of file

Modified: trunk/sat-solver/bindings/satsolver.i
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=7651&r1=7650&r2=7651&view=diff
==============================================================================
--- trunk/sat-solver/bindings/satsolver.i (original)
+++ trunk/sat-solver/bindings/satsolver.i Fri Oct 26 15:57:13 2007
@@ -2,7 +2,10 @@

%{

+extern "C"
+{
#include "ruby.h"
+#include "rubyio.h"
#include "bitmap.h"
#include "evr.h"
#include "hash.h"
@@ -16,17 +19,55 @@
#include "solver.h"
#include "source.h"
#include "source_solv.h"
+}

-#define true (1==1)
-#define false !true

%}

+/*%typemap(ruby, in) FILE* {
+ Check_Type($input, T_FILE);
+ $1 = RFILE($input)->fptr;
+
+}*/
+
+%typemap(ruby,in) FILE * {
+ OpenFile *fptr;
+
+ Check_Type($input, T_FILE);
+ GetOpenFile($input, fptr);
+ /*rb_io_check_writable(fptr);*/
+ $1 = GetReadFile(fptr);
+}
+
%include "bitmap.h"
%include "evr.h"
%include "hash.h"
%include "poolarch.h"
+
+
+%alias Pool::nsolvables "size"
%include "pool.h"
+%extend _Pool {
+
+ int installable(Solvable *s)
+ { return pool_installable($self,s); }
+
+ void prepare()
+ { pool_prepare($self);}
+
+ void each_source()
+ {
+ }
+
+ Source* add_empty_source()
+ {
+ return pool_addsource_empty($self);
+ }
+};
+%newobject pool_create;
+%delobject pool_free;
+
+
%include "poolid.h"
%include "poolid_private.h"
%include "pooltypes.h"
@@ -34,5 +75,26 @@
%include "solvable.h"
%include "solver.h"
%include "source.h"
+
+%extend Source {
+
+ void each_solvable()
+ {
+ int i, endof;
+ Solvable *s;
+ i = $self ? $self->start : 1;
+ endof = $self ? $self->start + $self->nsolvables : $self->pool->nsolvables;
+ for (; i < endof; i++)
+ {
+ s = $self->pool->solvables + i;
+ rb_yield(SWIG_NewPointerObj((void*) s, $descriptor(storetype), 0));
+ }
+ }
+};
+
%include "source_solv.h"

+%typemap(in) Id {
+ $1 = (int) NUM2INT($input);
+ printf("Received an integer : %d\n",$1);
+}

Modified: trunk/sat-solver/src/pool.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.c?rev=7651&r1=7650&r2=7651&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.c (original)
+++ trunk/sat-solver/src/pool.c Fri Oct 26 15:57:13 2007
@@ -64,6 +64,7 @@
Pool *
pool_create(void)
{
+ printf("POOL CREATE");
int count, totalsize = 0;
Pool *pool;
Solvable *s;

Modified: trunk/sat-solver/src/pool.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=7651&r1=7650&r2=7651&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.h (original)
+++ trunk/sat-solver/src/pool.h Fri Oct 26 15:57:13 2007
@@ -17,8 +17,8 @@
#include "queue.h"

// bool
-#ifndef SWIG
#ifndef __cplusplus
+#ifndef SWIG
typedef _Bool bool;
#endif
#endif
@@ -76,11 +76,8 @@
Solvable *solvables;
int nsolvables;

-#ifdef SWIG
- _Bool promoteepoch;
-#else
bool promoteepoch;
-#endif
+
Id *id2arch; /* map arch ids to scores */
Id lastarch; /* last valid entry in id2arch */


--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages