Added a partial specialization for swig::GC_VALUE
to avoid the need to check each element in the container during copy constructors. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9828 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0b36bc6940
commit
5aaf3003b6
1 changed files with 41 additions and 1 deletions
|
|
@ -400,7 +400,7 @@ namespace swig
|
|||
|
||||
bool check(bool set_err = true) const
|
||||
{
|
||||
int s = size();
|
||||
int s = (int) size();
|
||||
for (int i = 0; i < s; ++i) {
|
||||
VALUE item = rb_ary_entry(_seq, i );
|
||||
if (!swig::check<value_type>(item)) {
|
||||
|
|
@ -1072,6 +1072,46 @@ namespace swig {
|
|||
}
|
||||
};
|
||||
|
||||
// Partial specialization for GC_VALUE's. No need to typecheck each
|
||||
// element.
|
||||
template< class Seq >
|
||||
struct traits_asptr_stdseq< Seq, swig::GC_VALUE > {
|
||||
typedef Seq sequence;
|
||||
typedef swig::GC_VALUE value_type;
|
||||
|
||||
static int asptr(VALUE obj, sequence **seq) {
|
||||
if (rb_obj_is_kind_of(obj, rb_cArray) == Qtrue) {
|
||||
try {
|
||||
if (seq) {
|
||||
RubySequence_Cont<value_type> rubyseq(obj);
|
||||
sequence *pseq = new sequence();
|
||||
assign(rubyseq, pseq);
|
||||
*seq = pseq;
|
||||
return SWIG_NEWOBJ;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
if (seq) {
|
||||
VALUE lastErr = rb_gv_get("$!");
|
||||
if (lastErr == Qnil) {
|
||||
rb_raise(rb_eTypeError, e.what());
|
||||
}
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
sequence *p;
|
||||
if (SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
||||
if (seq) *seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Seq, class T = typename Seq::value_type >
|
||||
struct traits_from_stdseq {
|
||||
typedef Seq sequence;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue