Improved algorithm of renaming of methods with numbers at the end.
Fixed some const issues. Improved report on overloaded function error. Fixed some minor iterator potential problems. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9770 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e90e28acfc
commit
4cd98d3865
13 changed files with 96 additions and 26 deletions
|
|
@ -114,3 +114,11 @@ SWIG_STD_VECTOR_SPECIALIZE(MyClass, MyClass *)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(SWIGRUBY)
|
||||||
|
%template(LanguageVector) std::vector< swig::LANGUAGE_OBJ >;
|
||||||
|
|
||||||
|
%inline {
|
||||||
|
std::vector< swig::LANGUAGE_OBJ > LanguageVector;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ C_TEST_CASES += \
|
||||||
include $(srcdir)/../common.mk
|
include $(srcdir)/../common.mk
|
||||||
|
|
||||||
# Overridden variables here
|
# Overridden variables here
|
||||||
SWIGOPT += -noautorename -features autodoc=4
|
SWIGOPT += -w801 -noautorename -features autodoc=4
|
||||||
|
|
||||||
|
|
||||||
# Rules for the different types of tests
|
# Rules for the different types of tests
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,9 @@ dv.kind_of? DoubleVector
|
||||||
halved = []
|
halved = []
|
||||||
halved = dv.map { |x| x / 2 }
|
halved = dv.map { |x| x / 2 }
|
||||||
halve_in_place(dv)
|
halve_in_place(dv)
|
||||||
halved == dv.to_a
|
p halved.to_a
|
||||||
|
p dv.to_a
|
||||||
|
halved.to_a == dv.to_a
|
||||||
sv = StructVector.new
|
sv = StructVector.new
|
||||||
sv << Li_std_vector::Struct.new
|
sv << Li_std_vector::Struct.new
|
||||||
sv[0].class == Li_std_vector::Struct
|
sv[0].class == Li_std_vector::Struct
|
||||||
|
|
@ -98,3 +100,18 @@ sv[1] = Li_std_vector::Struct.new
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
swig_assert_each_line(<<'EOF', binding)
|
||||||
|
lv = LanguageVector.new
|
||||||
|
lv << 1
|
||||||
|
lv << [1,2]
|
||||||
|
lv << 'asd'
|
||||||
|
lv[0], lv[1] = lv[1], lv[0]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# this should assert
|
||||||
|
begin
|
||||||
|
lv = LanguageVector.new('crapola')
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,13 @@ namespace swig {
|
||||||
|
|
||||||
%exception GC_VALUE {};
|
%exception GC_VALUE {};
|
||||||
|
|
||||||
|
|
||||||
%apply VALUE {GC_VALUE};
|
%apply VALUE {GC_VALUE};
|
||||||
|
|
||||||
|
// Make sure this is the last typecheck done
|
||||||
|
%typecheck(999999,noblock=1) GC_VALUE, GC_VALUE&,
|
||||||
|
const GC_VALUE& { $1 = 1; };
|
||||||
|
|
||||||
/* For input */
|
/* 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;
|
r = $input; $1 = &r;
|
||||||
|
|
|
||||||
|
|
@ -615,14 +615,15 @@ namespace swig
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Sequence* each()
|
Sequence* each()
|
||||||
{
|
{
|
||||||
if ( !rb_block_given_p() )
|
if ( !rb_block_given_p() )
|
||||||
rb_raise( rb_eArgError, "no block given");
|
rb_raise( rb_eArgError, "no block given");
|
||||||
|
|
||||||
VALUE r;
|
VALUE r;
|
||||||
Sequence::iterator i = self->begin();
|
Sequence::const_iterator i = self->begin();
|
||||||
Sequence::iterator e = self->end();
|
Sequence::const_iterator e = self->end();
|
||||||
for ( ; i != e; ++i )
|
for ( ; i != e; ++i )
|
||||||
{
|
{
|
||||||
r = swig::from<Sequence::value_type>(*i);
|
r = swig::from<Sequence::value_type>(*i);
|
||||||
|
|
@ -650,7 +651,6 @@ namespace swig
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
%rename("reject!") reject_bang;
|
%rename("reject!") reject_bang;
|
||||||
%alias reject_bang "delete_if";
|
%alias reject_bang "delete_if";
|
||||||
Sequence* reject_bang() {
|
Sequence* reject_bang() {
|
||||||
|
|
@ -971,7 +971,7 @@ namespace swig {
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
static int asptr(VALUE obj, sequence **seq) {
|
static int asptr(VALUE obj, sequence **seq) {
|
||||||
if (rb_obj_is_kind_of(obj, rb_cArray)) {
|
if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) {
|
||||||
try {
|
try {
|
||||||
RubySequence_Cont<value_type> rubyseq(obj);
|
RubySequence_Cont<value_type> rubyseq(obj);
|
||||||
if (seq) {
|
if (seq) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ namespace swig {
|
||||||
// Access iterator method, required by Ruby
|
// Access iterator method, required by Ruby
|
||||||
virtual VALUE value() const = 0;
|
virtual VALUE value() const = 0;
|
||||||
|
|
||||||
|
// // Set referenced object
|
||||||
|
// virtual bool set(VALUE v) = 0;
|
||||||
|
|
||||||
// Forward iterator method, required by Ruby
|
// Forward iterator method, required by Ruby
|
||||||
virtual RubySwigIterator *incr(size_t n = 1) = 0;
|
virtual RubySwigIterator *incr(size_t n = 1) = 0;
|
||||||
|
|
||||||
|
|
@ -133,7 +136,7 @@ namespace swig {
|
||||||
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
|
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
|
||||||
typedef RubySwigIterator_T<out_iterator> self_type;
|
typedef RubySwigIterator_T<out_iterator> self_type;
|
||||||
|
|
||||||
RubySwigIterator_T(out_iterator curr, VALUE seq)
|
RubySwigIterator_T(out_iterator curr, VALUE seq = Qnil)
|
||||||
: RubySwigIterator(seq), current(curr)
|
: RubySwigIterator(seq), current(curr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -191,15 +194,23 @@ namespace swig {
|
||||||
typedef RubySwigIterator_T<out_iterator> base;
|
typedef RubySwigIterator_T<out_iterator> base;
|
||||||
typedef RubySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
|
typedef RubySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
|
||||||
|
|
||||||
RubySwigIteratorOpen_T(out_iterator curr, VALUE seq)
|
RubySwigIteratorOpen_T(out_iterator curr, VALUE seq = Qnil)
|
||||||
: RubySwigIterator_T<OutIterator>(curr, seq)
|
: RubySwigIterator_T<OutIterator>(curr, seq)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE value() const {
|
virtual VALUE value() const {
|
||||||
return from(static_cast<const value_type&>(*(base::current)));
|
return from(static_cast<const value_type&>(*(base::current)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// virtual bool set(VALUE v) {
|
||||||
|
// value_type val;
|
||||||
|
// if ( !asval(v, &val) ) return SWIG_ERROR;
|
||||||
|
// *(base::current) = val;
|
||||||
|
// return SWIG_OK;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
RubySwigIterator *copy() const
|
RubySwigIterator *copy() const
|
||||||
{
|
{
|
||||||
return new self_type(*this);
|
return new self_type(*this);
|
||||||
|
|
@ -234,12 +245,12 @@ namespace swig {
|
||||||
typedef RubySwigIterator_T<out_iterator> base;
|
typedef RubySwigIterator_T<out_iterator> base;
|
||||||
typedef RubySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
|
typedef RubySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
|
||||||
|
|
||||||
RubySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, VALUE seq)
|
RubySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, VALUE seq = Qnil)
|
||||||
: RubySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
|
: RubySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE value() const {
|
virtual VALUE value() const {
|
||||||
if (base::current == end) {
|
if (base::current == end) {
|
||||||
throw stop_iteration();
|
throw stop_iteration();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -247,6 +258,13 @@ namespace swig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// virtual bool set(VALUE v) {
|
||||||
|
// value_type val;
|
||||||
|
// if ( !asval(v, &val) ) return SWIG_ERROR;
|
||||||
|
// *(base::current) = val;
|
||||||
|
// return SWIG_OK;
|
||||||
|
// }
|
||||||
|
|
||||||
RubySwigIterator *copy() const
|
RubySwigIterator *copy() const
|
||||||
{
|
{
|
||||||
return new self_type(*this);
|
return new self_type(*this);
|
||||||
|
|
@ -283,14 +301,14 @@ namespace swig {
|
||||||
|
|
||||||
template<typename OutIter>
|
template<typename OutIter>
|
||||||
inline RubySwigIterator*
|
inline RubySwigIterator*
|
||||||
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, VALUE seq = 0)
|
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, VALUE seq = Qnil)
|
||||||
{
|
{
|
||||||
return new RubySwigIteratorClosed_T<OutIter>(current, begin, end, seq);
|
return new RubySwigIteratorClosed_T<OutIter>(current, begin, end, seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OutIter>
|
template<typename OutIter>
|
||||||
inline RubySwigIterator*
|
inline RubySwigIterator*
|
||||||
make_output_iterator(const OutIter& current, VALUE seq = 0)
|
make_output_iterator(const OutIter& current, VALUE seq = Qnil)
|
||||||
{
|
{
|
||||||
return new RubySwigIteratorOpen_T<OutIter>(current, seq);
|
return new RubySwigIteratorOpen_T<OutIter>(current, seq);
|
||||||
}
|
}
|
||||||
|
|
@ -347,6 +365,9 @@ namespace swig
|
||||||
// Access iterator method, required by Ruby
|
// Access iterator method, required by Ruby
|
||||||
virtual VALUE value() const = 0;
|
virtual VALUE value() const = 0;
|
||||||
|
|
||||||
|
// // Set referenced object, required by Ruby
|
||||||
|
// virtual bool set(VALUE val) = 0;
|
||||||
|
|
||||||
// Forward iterator method, required by Ruby
|
// Forward iterator method, required by Ruby
|
||||||
virtual RubySwigIterator *incr(size_t n = 1) = 0;
|
virtual RubySwigIterator *incr(size_t n = 1) = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,9 @@
|
||||||
|
|
||||||
#define %argnullref_fmt(_type,_name,_argn) Ruby_Format_TypeError(%nullref_fmt(), _type, #_name, _argn, $input)
|
#define %argnullref_fmt(_type,_name,_argn) Ruby_Format_TypeError(%nullref_fmt(), _type, #_name, _argn, $input)
|
||||||
|
|
||||||
|
%{
|
||||||
|
#define SWIG_RUBY_THREAD_BEGIN_BLOCK
|
||||||
|
#define SWIG_RUBY_THREAD_END_BLOCK
|
||||||
|
%}
|
||||||
|
|
||||||
%include <typemaps/swigmacros.swg>
|
%include <typemaps/swigmacros.swg>
|
||||||
|
|
|
||||||
|
|
@ -394,6 +394,19 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
|
||||||
rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
|
rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function can be used to check whether a proc or method or similarly
|
||||||
|
callable function has been passed. Usually used in a %typecheck. */
|
||||||
|
SWIGINTERN
|
||||||
|
int rb_is_callable( VALUE proc )
|
||||||
|
{
|
||||||
|
static VALUE call_id = Qnil;
|
||||||
|
if ( call_id == Qnil ) call_id = rb_intern("call");
|
||||||
|
if ( rb_respond_to( proc, call_id ) )
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,3 @@ namespace swig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define SWIG_RUBY_THREAD_BEGIN_BLOCK
|
|
||||||
#define SWIG_RUBY_THREAD_END_BLOCK
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@
|
||||||
$1 = &self;
|
$1 = &self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Include the unified typemap library */
|
/* Include the unified typemap library */
|
||||||
%include <typemaps/swigtypemaps.swg>
|
%include <typemaps/swigtypemaps.swg>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,13 @@
|
||||||
|
|
||||||
%extend {
|
%extend {
|
||||||
%alias push "<<";
|
%alias push "<<";
|
||||||
value_type push(value_type x) {
|
value_type push(const value_type& x) {
|
||||||
self->insert(x);
|
self->insert(x);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
%rename("include?") __contains__;
|
%rename("include?") __contains__;
|
||||||
bool __contains__(value_type x) {
|
bool __contains__(const value_type& x) {
|
||||||
return self->find(x) != self->end();
|
return self->find(x) != self->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2012,7 +2012,7 @@ public:
|
||||||
String* methodName = NewString("");
|
String* methodName = NewString("");
|
||||||
if ( isMethod )
|
if ( isMethod )
|
||||||
Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL );
|
Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL );
|
||||||
Append( methodName, Getattr(sibl,"name" ) );
|
Append( methodName, Getattr(sibl,"sym:name" ) );
|
||||||
if ( isCtor ) Append( methodName, ".new" );
|
if ( isCtor ) Append( methodName, ".new" );
|
||||||
|
|
||||||
// Generate prototype list
|
// Generate prototype list
|
||||||
|
|
|
||||||
|
|
@ -236,25 +236,32 @@ String *Swig_string_lccase(String *s) {
|
||||||
* This is the reverse case of ccase, ie
|
* This is the reverse case of ccase, ie
|
||||||
*
|
*
|
||||||
* CamelCase -> camel_case
|
* CamelCase -> camel_case
|
||||||
|
* get2D -> get_2d
|
||||||
|
* asFloat2 -> as_float2
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *Swig_string_ucase(String *s) {
|
String *Swig_string_ucase(String *s) {
|
||||||
String *ns;
|
String *ns;
|
||||||
int c;
|
int c;
|
||||||
int lastC = 0;
|
int lastC = 0;
|
||||||
|
int nextC = 0;
|
||||||
int underscore = 0;
|
int underscore = 0;
|
||||||
ns = NewStringEmpty();
|
ns = NewStringEmpty();
|
||||||
|
|
||||||
/* We insert a underscore when:
|
/* We insert a underscore when:
|
||||||
1. Lower case char followed by upper case char
|
1. Lower case char followed by upper case char
|
||||||
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
|
getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
|
||||||
2. Number proceded by char
|
2. Number proceded by char and not end of string
|
||||||
get2D > get_2d; get22D > get_22d; GET2D > get_2d */
|
get2D > get_2d; get22D > get_22d; GET2D > get_2d
|
||||||
|
but:
|
||||||
|
asFloat2 > as_float2
|
||||||
|
*/
|
||||||
|
|
||||||
Seek(s, 0, SEEK_SET);
|
Seek(s, 0, SEEK_SET);
|
||||||
|
|
||||||
while ((c = Getc(s)) != EOF) {
|
while ((c = Getc(s)) != EOF) {
|
||||||
if (isdigit(c) && isalpha(lastC))
|
nextC = Getc(s); Ungetc(nextC, s);
|
||||||
|
if (isdigit(c) && isalpha(lastC) && nextC != EOF)
|
||||||
underscore = 1;
|
underscore = 1;
|
||||||
else if (isupper(c) && isalpha(lastC) && !isupper(lastC))
|
else if (isupper(c) && isalpha(lastC) && !isupper(lastC))
|
||||||
underscore = 1;
|
underscore = 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue