From: gga Date: 2007-06-19T18:45:10+09:00 Subject: Re: Problem wrapping the C++ STL On Jun 18, 11:15 am, Daniel Berger wrote: > > Is it possible to wrap the C++ STL stuff? Say, for example, vector? > Absolutely. But I suggest you download the latest swig from svn, as it contains a lot of enhancements for this. This is how you do it in swig. ---- mystl.i ---- %module mystl %include std_vector.i // GC_VALUE is a special class that knows how to mark itself. %template(ValueVector) std::vector< GC_VALUE >; ----- end mystl.i ---- On a console: $ swig -ruby -c++ mystl.i # creates mystl_wrap.cxx Compile: # using extconf.rb (recommended) or... # # posix # $ g++ -fPIC -DPIC -O2 mystl_wrap.cxx -o mystl_wrap.so -lruby -lstdc++ # # Windows # $ vcvars32.bat $ cl.exe -MD -LD -O2 mystl_wrap.cxx -o mystl_wrap.so /link msvcrt- ruby1.8.dll ------ usage ----- require 'mystl' include Mystl a = ValueVector.new puts a.methods # you'll get iterators, most array methods, etc. -------------------