diff --git a/SWIG/Doc/Manual/Mzscheme.html b/SWIG/Doc/Manual/Mzscheme.html index ef14580ba..699168322 100644 --- a/SWIG/Doc/Manual/Mzscheme.html +++ b/SWIG/Doc/Manual/Mzscheme.html @@ -33,12 +33,12 @@ Example interface file:
/* define a macro for the struct creation */
%define handle_ptr(TYPE,NAME)
-%typemap(mzscheme,argout) TYPE *NAME{
+%typemap(argout) TYPE *NAME{
Scheme_Object *o = SWIG_NewStructFromPtr($1, $*1_mangle);
SWIG_APPEND_VALUE(o);
}
-%typemap(mzscheme,in,numinputs=0) TYPE *NAME (TYPE temp) {
+%typemap(in,numinputs=0) TYPE *NAME (TYPE temp) {
$1 = &temp;
}
%enddef
diff --git a/SWIG/Doc/Manual/Ruby.html b/SWIG/Doc/Manual/Ruby.html
index 72b9b600d..af4154ebf 100644
--- a/SWIG/Doc/Manual/Ruby.html
+++ b/SWIG/Doc/Manual/Ruby.html
@@ -1766,7 +1766,7 @@ $ ruby -e 'puts $:.join("\n")'
/usr/local/lib/ruby/site_ruby/1.6 /usr/
similar typemaps for other STL structures:
- %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(ruby, out) vectorclassname &, const vectorclassname & {
VALUE arr = rb_ary_new2($1->size());
vectorclassname::iterator i = $1->begin(), iend = $1->end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
$result = arr;
}
%typemap(ruby, out) vectorclassname, const vectorclassname {
VALUE arr = rb_ary_new2($1.size());
vectorclassname::iterator i = $1.begin(), iend = $1.end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
$result = arr;
}
%enddef
+ %define PTR_VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(out) vectorclassname &, const vectorclassname & {
VALUE arr = rb_ary_new2($1->size());
vectorclassname::iterator i = $1->begin(), iend = $1->end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
$result = arr;
}
%typemap(out) vectorclassname, const vectorclassname {
VALUE arr = rb_ary_new2($1.size());
vectorclassname::iterator i = $1.begin(), iend = $1.end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, *i));
$result = arr;
}
%enddef
Note, that the "c ## classname.klass" is used in the preprocessor step
@@ -1781,13 +1781,13 @@ $ ruby -e 'puts $:.join("\n")'
/usr/local/lib/ruby/site_ruby/1.6 /usr/
It is also possible to create a STL vector of Ruby objects:
- %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
%typemap(ruby, in) vectorclassname &, const vectorclassname & {
Check_Type($input, T_ARRAY);
vectorclassname *vec = new vectorclassname;
int len = RARRAY($input)->len;
for (int i=0; i!=len; i++) {
VALUE inst = rb_ary_entry($input, i);
//The following _should_ work but doesn't on HPUX
// Check_Type(inst, T_DATA);
classname *element = NULL;
Data_Get_Struct(inst, classname, element);
vec->push_back(element);
}
$1 = vec;
}
%typemap(ruby, freearg) vectorclassname &, const vectorclassname & {
delete $1;
}
%enddef
+ %define RUBY_ARRAY_TO_PTR_VECTOR(vectorclassname, classname)
%typemap(in) vectorclassname &, const vectorclassname & {
Check_Type($input, T_ARRAY);
vectorclassname *vec = new vectorclassname;
int len = RARRAY($input)->len;
for (int i=0; i!=len; i++) {
VALUE inst = rb_ary_entry($input, i);
//The following _should_ work but doesn't on HPUX
// Check_Type(inst, T_DATA);
classname *element = NULL;
Data_Get_Struct(inst, classname, element);
vec->push_back(element);
}
$1 = vec;
}
%typemap(freearg) vectorclassname &, const vectorclassname & {
delete $1;
}
%enddef
It is also possible to create a Ruby array from a vector of static data types:
- %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(ruby, out) vectorclassname &, const vectorclassname & {
VALUE arr = rb_ary_new2($1->size());
vectorclassname::iterator i = $1->begin(), iend = $1->end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
$result = arr;
}
%typemap(ruby, out) vectorclassname, const vectorclassname {
VALUE arr = rb_ary_new2($1.size());
vectorclassname::iterator i = $1.begin(), iend = $1.end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
$result = arr;
}
%enddef
+ %define VECTOR_TO_RUBY_ARRAY(vectorclassname, classname)
%typemap(out) vectorclassname &, const vectorclassname & {
VALUE arr = rb_ary_new2($1->size());
vectorclassname::iterator i = $1->begin(), iend = $1->end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
$result = arr;
}
%typemap(out) vectorclassname, const vectorclassname {
VALUE arr = rb_ary_new2($1.size());
vectorclassname::iterator i = $1.begin(), iend = $1.end();
for ( ; i!=iend; i++ )
rb_ary_push(arr, Data_Wrap_Struct(c ## classname.klass, 0, 0, &(*i)));
$result = arr;
}
%enddef
30.7 Advanced Topics
diff --git a/SWIG/Doc/Manual/Typemaps.html b/SWIG/Doc/Manual/Typemaps.html
index 412f8065a..d726e3e63 100644
--- a/SWIG/Doc/Manual/Typemaps.html
+++ b/SWIG/Doc/Manual/Typemaps.html
@@ -2350,7 +2350,7 @@ array dimensions. Multidimensional arrays can be matched in a similar manner.
-%typemap(python,in) float matrix[ANY][ANY] (float temp[$1_dim0][$1_dim1]) {
+%typemap(in) float matrix[ANY][ANY] (float temp[$1_dim0][$1_dim1]) {
... convert a 2d array ...
}