Rename fixes to STL.
Removed object reporting in non-verbose from newobject demos. Made wstring treat them as normal strings as advertised. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9771 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4cd98d3865
commit
81c84b7e8c
16 changed files with 131 additions and 125 deletions
|
|
@ -1,6 +1,34 @@
|
|||
Version 1.3.32 (in progress)
|
||||
============================
|
||||
|
||||
05/04/2007: gga
|
||||
[Ruby]
|
||||
Changed STL renames to be global renames. This fixes
|
||||
STL functions not being renamed when autorename is on.
|
||||
This is a not a totally perfect work-around, but better.
|
||||
Someone really needs to fix the template renaming code.
|
||||
(See bug #1545634)
|
||||
|
||||
05/04/2007 gga
|
||||
[All]
|
||||
Changed %rename("%(undercase)s") a little so that single
|
||||
numbers at the end of a function are not undercased. That is:
|
||||
getSomething -> get_something
|
||||
get2D -> get_2d
|
||||
get234 -> get_234
|
||||
BUT:
|
||||
asFloat2 -> as_float2
|
||||
(Bug #1699714)
|
||||
|
||||
05/03/2007: gga
|
||||
[Ruby]
|
||||
Made __swigtype__ => @__swigtype__ so it can be accessed
|
||||
from the scripting language (and follows Ruby's official
|
||||
documentation, just in case).
|
||||
Made tracking => @__trackings__ for same reason.
|
||||
Currently storing ivars without the @ seems valid, but
|
||||
the PickAxe says this is not correct, so just in case...
|
||||
|
||||
05/03/2007: gga
|
||||
[Ruby]
|
||||
Applied patch for -minherit bug and exception classes.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ include Newobject1
|
|||
GC.track_class = Foo
|
||||
GC.start
|
||||
100.times { foo1 = Foo.makeFoo; foo2 = foo1.makeMore }
|
||||
GC.stats
|
||||
GC.stats if $VERBOSE
|
||||
swig_assert( 'Foo.fooCount == 200', binding, "but is #{Foo.fooCount}" )
|
||||
GC.start
|
||||
swig_assert( 'Foo.fooCount <= 2', binding, "but is #{Foo.fooCount}" )
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ include Newobject2
|
|||
GC.track_class = Foo
|
||||
GC.stats
|
||||
100.times { foo1 = makeFoo }
|
||||
GC.stats
|
||||
GC.stats if $VERBOSE
|
||||
swig_assert( 'fooCount == 100', nil, "but is #{fooCount}" )
|
||||
GC.start
|
||||
swig_assert( 'fooCount <= 1', nil, "but is #{fooCount}" )
|
||||
|
|
|
|||
|
|
@ -576,15 +576,13 @@ namespace swig
|
|||
|
||||
%fragment("RubySequence_Base");
|
||||
|
||||
|
||||
%extend {
|
||||
|
||||
|
||||
// Implementing delete requires semantics that go beyond the
|
||||
// default requirements of STD containers.
|
||||
//
|
||||
// %rename("delete") __del__;
|
||||
// VALUE __del__( Sequence::value_type e ) {
|
||||
// VALUE __delete__( Sequence::value_type e ) {
|
||||
// VALUE r = Qnil;
|
||||
// std::size_t len = $self->size();
|
||||
// std::remove_if( $self->begin(), $self->end(),
|
||||
|
|
@ -651,7 +649,6 @@ namespace swig
|
|||
return r;
|
||||
}
|
||||
|
||||
%rename("reject!") reject_bang;
|
||||
%alias reject_bang "delete_if";
|
||||
Sequence* reject_bang() {
|
||||
if ( !rb_block_given_p() )
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
|
|||
It might not in cases where methods do things like
|
||||
downcast methods. */
|
||||
if (obj != Qnil) {
|
||||
VALUE value = rb_iv_get(obj, "__swigtype__");
|
||||
VALUE value = rb_iv_get(obj, "@__swigtype__");
|
||||
char* type_name = RSTRING_PTR(value);
|
||||
|
||||
if (strcmp(type->name, type_name) == 0) {
|
||||
|
|
@ -210,7 +210,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
|
|||
free((void *) klass_name);
|
||||
obj = Data_Wrap_Struct(klass, 0, 0, ptr);
|
||||
}
|
||||
rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name));
|
||||
rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
|
|||
VALUE obj;
|
||||
swig_class *sklass = (swig_class *) type->clientdata;
|
||||
obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0);
|
||||
rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name));
|
||||
rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
|
|||
SWIGRUNTIMEINLINE char *
|
||||
SWIG_Ruby_MangleStr(VALUE obj)
|
||||
{
|
||||
VALUE stype = rb_iv_get(obj, "__swigtype__");
|
||||
VALUE stype = rb_iv_get(obj, "@__swigtype__");
|
||||
return StringValuePtr(stype);
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ SWIG_Ruby_SetModule(swig_module_info *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 )
|
||||
int SWIG_Ruby_isCallable( VALUE proc )
|
||||
{
|
||||
static VALUE call_id = Qnil;
|
||||
if ( call_id == Qnil ) call_id = rb_intern("call");
|
||||
|
|
|
|||
|
|
@ -200,3 +200,24 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Common renames for STL functions.
|
||||
// Sadly, SWIG's name matching is still primitive, so:
|
||||
//
|
||||
// std::*::push_back is not valid
|
||||
//
|
||||
// Also, since these get run inside templates, putting
|
||||
// the rename inside the template %extend section is no good
|
||||
// either.
|
||||
//
|
||||
|
||||
%rename("delete") *::__delete__;
|
||||
%rename("reject!") *::reject_bang;
|
||||
%rename("map!") *::map_bang;
|
||||
%rename("push") *::push_back;
|
||||
%rename("pop") *::pop_back;
|
||||
%rename("empty?") *::empty;
|
||||
%rename("include?" ) *::__contains__ const;
|
||||
%rename("has_key?" ) *::has_key const;
|
||||
%alias push "<<";
|
||||
%alias push_back "<<";
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
|
|||
This is done to allow multiple DSOs to share the same
|
||||
tracking table.
|
||||
*/
|
||||
ID trackings_id = rb_intern( "trackings" );
|
||||
ID trackings_id = rb_intern( "@__trackings__" );
|
||||
VALUE verbose = rb_gv_get("VERBOSE");
|
||||
rb_gv_set("VERBOSE", Qfalse);
|
||||
swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
|
||||
|
|
|
|||
|
|
@ -1,3 +1,16 @@
|
|||
/**
|
||||
* @file rubywstrings.swg
|
||||
* @author
|
||||
* @date Fri May 4 17:49:40 2007
|
||||
*
|
||||
* @brief Currently, Ruby does not support Unicode or WChar properly, so these
|
||||
* are still treated as char arrays for now.
|
||||
* There are other libraries available that add support to this in
|
||||
* ruby including WString, FXString, etc.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* utility methods for wchar_t strings
|
||||
* ------------------------------------------------------------ */
|
||||
|
|
@ -6,39 +19,38 @@
|
|||
SWIGINTERN int
|
||||
SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
|
||||
{
|
||||
VALUE tmp = 0;
|
||||
bool ok = false;
|
||||
if ( TYPE(obj) == T_STRING ) {
|
||||
if (cptr) {
|
||||
// obj = tmp = PyUnicode_FromObject(obj);
|
||||
rb_notimplement();
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc);
|
||||
// VALUE tmp = 0;
|
||||
// bool ok = false;
|
||||
// if ( TYPE(obj) == T_STRING ) {
|
||||
// if (cptr) {
|
||||
// obj = tmp = SWIG_Unicode_FromObject(obj);
|
||||
// ok = true;
|
||||
// }
|
||||
// }
|
||||
// if (ok) {
|
||||
// int len = PyUnicode_GetSize(obj);
|
||||
rb_notimplement();
|
||||
if (cptr) {
|
||||
*cptr = %new_array(len + 1, wchar_t);
|
||||
// PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
|
||||
rb_notimplement();
|
||||
(*cptr)[len] = 0;
|
||||
}
|
||||
if (psize) *psize = (size_t) len + 1;
|
||||
if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
||||
if (pwchar_descriptor) {
|
||||
void * vptr = 0;
|
||||
if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
|
||||
if (cptr) *cptr = (wchar_t *)vptr;
|
||||
if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SWIG_TypeError;
|
||||
// rb_notimplement();
|
||||
// if (cptr) {
|
||||
// *cptr = %new_array(len + 1, wchar_t);
|
||||
// SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
|
||||
// (*cptr)[len] = 0;
|
||||
// }
|
||||
// if (psize) *psize = (size_t) len + 1;
|
||||
// if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
|
||||
// return SWIG_OK;
|
||||
// } else {
|
||||
// swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
||||
// if (pwchar_descriptor) {
|
||||
// void * vptr = 0;
|
||||
// if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
|
||||
// if (cptr) *cptr = (wchar_t *)vptr;
|
||||
// if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
|
||||
// return SWIG_OK;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return SWIG_TypeError;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,18 +58,18 @@ SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
|
|||
SWIGINTERNINLINE VALUE
|
||||
SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
|
||||
{
|
||||
if (carray) {
|
||||
if (size > INT_MAX) {
|
||||
swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
||||
return pwchar_descriptor ?
|
||||
SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil;
|
||||
} else {
|
||||
rb_notimplement();
|
||||
// return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
|
||||
}
|
||||
} else {
|
||||
return Qnil;
|
||||
}
|
||||
return SWIG_FromCharPtrAndSize( (const char**)cptr, size);
|
||||
// if (carray) {
|
||||
// if (size > INT_MAX) {
|
||||
// swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
||||
// return pwchar_descriptor ?
|
||||
// SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil;
|
||||
// } else {
|
||||
// return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int));
|
||||
// }
|
||||
// } else {
|
||||
// return Qnil;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
}
|
||||
%}
|
||||
|
||||
%ignore std::deque::push_back;
|
||||
%ignore std::deque::pop_back;
|
||||
|
||||
#define %swig_deque_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
}
|
||||
%}
|
||||
|
||||
%ignore std::list::push_back;
|
||||
%ignore std::list::pop_back;
|
||||
|
||||
#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
|
|
|
|||
|
|
@ -137,8 +137,7 @@
|
|||
|
||||
%extend {
|
||||
|
||||
%rename("delete") __delitem__;
|
||||
VALUE __delitem__(const key_type& key) {
|
||||
VALUE __delete__(const key_type& key) {
|
||||
Map::iterator i = self->find(key);
|
||||
if (i != self->end()) {
|
||||
self->erase(i);
|
||||
|
|
@ -149,7 +148,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
%rename("has_key?") has_key;
|
||||
bool has_key(const key_type& key) const {
|
||||
Map::const_iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
|
|
@ -306,7 +304,6 @@
|
|||
return ary;
|
||||
}
|
||||
|
||||
%rename("include?") __contains__;
|
||||
bool __contains__(const key_type& key) {
|
||||
return self->find(key) != self->end();
|
||||
}
|
||||
|
|
@ -399,16 +396,6 @@
|
|||
%enddef
|
||||
|
||||
|
||||
#if defined(SWIG_RUBY_AUTORENAME)
|
||||
|
||||
%mixin std::map "Enumerable";
|
||||
%rename("empty?") std::map::empty;
|
||||
|
||||
#else
|
||||
|
||||
%mixin std::map "Enumerable";
|
||||
%rename("empty?") std::map::empty;
|
||||
|
||||
#endif
|
||||
%mixin std::map "Enumerable";
|
||||
|
||||
%include <std/std_map.i>
|
||||
|
|
|
|||
|
|
@ -211,17 +211,7 @@
|
|||
%enddef
|
||||
|
||||
|
||||
#if defined(SWIG_RUBY_AUTORENAME)
|
||||
|
||||
%mixin std::multimap "Enumerable";
|
||||
%rename("empty?") std::multimap::empty;
|
||||
|
||||
#else
|
||||
|
||||
%mixin std::multimap "Enumerable";
|
||||
%rename("empty?") std::multimap::empty;
|
||||
|
||||
#endif
|
||||
%mixin std::multimap "Enumerable";
|
||||
|
||||
%include <std/std_multimap.i>
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
return x;
|
||||
}
|
||||
|
||||
%rename("include?") __contains__;
|
||||
bool __contains__(const value_type& x) {
|
||||
return self->find(x) != self->end();
|
||||
}
|
||||
|
|
@ -57,17 +56,7 @@
|
|||
};
|
||||
%enddef
|
||||
|
||||
#if defined(SWIG_RUBY_AUTORENAME)
|
||||
|
||||
%mixin std::set "Enumerable";
|
||||
%rename("empty?") std::set::empty;
|
||||
|
||||
#else
|
||||
|
||||
%mixin std::set "Enumerable";
|
||||
%rename("empty?") std::set::empty;
|
||||
|
||||
#endif
|
||||
|
||||
%mixin std::set "Enumerable";
|
||||
|
||||
%include <std/std_set.i>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,5 @@
|
|||
|
||||
AUTODOC(substr, "Return a portion of the String");
|
||||
|
||||
%rename("empty?") std::string::empty;
|
||||
%rename("empty?") std::basic_string::empty;
|
||||
|
||||
%include <typemaps/std_string.swg>
|
||||
|
||||
|
|
|
|||
|
|
@ -34,21 +34,9 @@
|
|||
%enddef
|
||||
|
||||
|
||||
#if defined(SWIG_RUBY_AUTORENAME)
|
||||
|
||||
%mixin std::vector "Enumerable";
|
||||
%rename("empty?") std::vector::empty;
|
||||
%ignore std::vector::push_back;
|
||||
%ignore std::vector::pop_back;
|
||||
|
||||
#else
|
||||
|
||||
%mixin std::vector "Enumerable";
|
||||
%rename("empty?") std::vector::empty;
|
||||
%ignore std::vector::push_back;
|
||||
%ignore std::vector::pop_back;
|
||||
|
||||
#endif
|
||||
%mixin std::vector "Enumerable";
|
||||
%ignore std::vector::push_back;
|
||||
%ignore std::vector::pop_back;
|
||||
|
||||
%include <std/std_vector.i>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,18 +28,9 @@
|
|||
#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
#if defined(SWIG_RUBY_AUTORENAME)
|
||||
|
||||
%rename("empty?") std::vector::empty;
|
||||
%ignore std::vector::push_back;
|
||||
%ignore std::vector::pop_back;
|
||||
%alias std::vector::push "<<";
|
||||
|
||||
#else
|
||||
%rename("empty?") std::vector::empty;
|
||||
%ignore std::vector::push_back;
|
||||
%ignore std::vector::pop_back;
|
||||
%alias std::vector::push "<<";
|
||||
#endif
|
||||
%mixin std::vector "Enumerable";
|
||||
%ignore std::vector::push_back;
|
||||
%ignore std::vector::pop_back;
|
||||
%alias std::vector::push "<<";
|
||||
|
||||
%include <std/std_vectora.i>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue