Moved the GC_VALUE class over to rubystdcommon

so that it will only get added when STL is used.

Documented swig_assert interface.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9731 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Gonzalo Garramuno 2007-05-01 01:21:26 +00:00
commit 293750eaea
4 changed files with 46 additions and 17 deletions

View file

@ -8,19 +8,30 @@
#
#
# Exception raised when some swig binding test fails
#
class SwigRubyError < RuntimeError
end
class SwigAssertError < StandardError
end
#
# Asserts whether a and b are equal.
#
# scope - optional Binding where to run the code
# msg - optional additional message to print
#
def swig_assert_equal( a, b, scope = nil, msg = nil )
begin
check = "#{a} == #{b}"
ok = eval(check, scope)
if scope.kind_of? Binding
ok = eval(check.to_s, scope)
else
ok = eval(check.to_s)
msg = scope if !msg
end
rescue => e
raise SwigAssertError.new("Wrong assert: #{check} - #{e}")
raise
end
unless ok
@ -42,19 +53,25 @@ rescue => e
end
def swig_assert( condition, scope = nil, msg = nil )
#
# Asserts whether an expression runs properly
#
# scope - optional Binding where to run the code
# msg - optional additional message to print
#
def swig_assert( expr, scope = nil, msg = nil )
begin
if scope.kind_of? Binding
eval(condition.to_s, scope)
eval(expr.to_s, scope)
else
eval(condition.to_s)
msg = scope
eval(expr.to_s)
msg = scope if !msg
end
rescue => e
raise SwigAssertError.new("Wrong assert: #{condition.to_s} - #{e}")
raise SwigRubyError.new("Wrong assert: #{expr.to_s} - #{e}")
end
if $VERBOSE
$stdout.puts "\tPASSED #{condition} #{msg}"
$stdout.puts "\tPASSED #{expr} #{msg}"
end
rescue => e
trace = e.backtrace[1..-1]
@ -66,6 +83,15 @@ rescue => e
end
#
# Given a set of lines as text, runs each of them, asserting them.
# Lines that are of the form:
# a == b are run with swig_assert_equal
# others are run with swig_assert.
#
# scope - optional Binding where to run the code
# msg - optional additional message to print
#
def swig_assert_each_line( lines, scope = nil, msg = nil )
lines.split("\n").each do |line|
next if line.empty? or line =~ /^\s*#.*/

View file

@ -53,11 +53,6 @@
* ------------------------------------------------------------ */
%include <rubyopers.swg>
/* ------------------------------------------------------------
* The Ruby classes, for C++
* ------------------------------------------------------------ */
%include <rubyclasses.swg>
/* ------------------------------------------------------------
* Warnings for Ruby keywords
* ------------------------------------------------------------ */

View file

@ -41,10 +41,12 @@ namespace swig {
VALUE to_s() const;
};
%exception GC_VALUE {};
%apply VALUE {GC_VALUE};
/* For input */
%typemap(in,noblock=1) GC_VALUE* (GC_VALUE r), GC_VALUE& (GC_VALUE r) {
%typemap(in,noblock=1) GC_VALUE* (GC_VALUE r), GC_VALUE& (GC_VALUE r) {
r = $input; $1 = &r;
}

View file

@ -1,3 +1,9 @@
/* ------------------------------------------------------------
* The Ruby classes, for C++
* ------------------------------------------------------------ */
%include <rubyclasses.swg>
%fragment("StdTraits","header",fragment="StdTraitsCommon")
{