STL stream support for Ruby.
docstring and autodoc support for Ruby. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9750 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1992714551
commit
594483bbda
12 changed files with 630 additions and 3 deletions
59
Examples/test-suite/li_std_stream.i
Normal file
59
Examples/test-suite/li_std_stream.i
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
%module li_std_stream
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
%}
|
||||
|
||||
%include <std_iostream.i>
|
||||
%include <std_sstream.i>
|
||||
|
||||
|
||||
|
||||
%callback(1) A::bar;
|
||||
|
||||
%inline %{
|
||||
|
||||
struct B {
|
||||
virtual ~B()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct A : B
|
||||
{
|
||||
void __add__(int a)
|
||||
{
|
||||
}
|
||||
|
||||
void __add__(double a)
|
||||
{
|
||||
}
|
||||
|
||||
static int bar(int a){
|
||||
return a;
|
||||
}
|
||||
|
||||
static int foo(int a, int (*pf)(int a))
|
||||
{
|
||||
return pf(a);
|
||||
}
|
||||
|
||||
|
||||
std::ostream& __rlshift__(std::ostream& out)
|
||||
{
|
||||
out << "A class";
|
||||
return out;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
%extend std::basic_ostream<char>{
|
||||
std::basic_ostream<char>&
|
||||
operator<<(const A& a)
|
||||
{
|
||||
*self << "A class";
|
||||
return *self;
|
||||
}
|
||||
}
|
||||
|
||||
22
Examples/test-suite/ruby/li_std_stream_runme.rb
Executable file
22
Examples/test-suite/ruby/li_std_stream_runme.rb
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Simple test of std::ostringstream.
|
||||
#
|
||||
# Author:: gga
|
||||
# Copyright:: 2007
|
||||
# License:: Ruby
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'li_std_stream'
|
||||
include Li_std_stream
|
||||
|
||||
swig_assert_each_line(<<'EOF', binding)
|
||||
|
||||
a = A.new
|
||||
o = Ostringstream.new
|
||||
o << a << " " << 2345 << " " << 1.435
|
||||
o.str == "A class 2345 1.435"
|
||||
|
||||
EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue