[Ruby] Pass Qnil instead of NULL to rb_funcall()

This silences GCC -Wconversion-null warning (on by default with recent
GCC).
This commit is contained in:
Olly Betts 2018-04-03 18:01:58 +12:00
parent 5f5ab92d5e
commit 3bea8f6b7e
4 changed files with 17 additions and 13 deletions

View File

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.0.0 (in progress)
===========================
2018-04-03: olly
[Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC
-Wconversion-null warning (on by default with recent GCC).
2018-03-09: fultonwi
[Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression
for non-director classes. Restores a dynamic_cast which was previously removed.

View File

@ -3704,7 +3704,7 @@ value: </p>
<pre>%typemap(in) (int nattributes, const char **names, const int *values)
(VALUE keys_arr, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
<b>$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));</b>
<b>$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));</b>
}</pre>
</div>
@ -3717,7 +3717,7 @@ the keys and values from the hash: </p>
<pre>%typemap(in) (int nattributes, const char **names, const int *values)
(VALUE keys_arr, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
<b>$2 = NULL;
$3 = NULL;
if ($1 &gt; 0) {
@ -3736,13 +3736,13 @@ of the keys) and then start looping over the elements in that array: </p>
<pre>%typemap(in) (int nattributes, const char **names, const int *values)
(VALUE keys_arr, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
$2 = NULL;
$3 = NULL;
if ($1 &gt; 0) {
$2 = (char **) malloc($1*sizeof(char *));
$3 = (int *) malloc($1*sizeof(int));
<b>keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
<b>keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
for (i = 0; i &lt; $1; i++) {
}</b>
}
@ -3758,13 +3758,13 @@ corresponding to that key in the hash: </p>
<pre>%typemap(in) (int nattributes, const char **names, const int *values)
(VALUE keys_arr, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
$2 = NULL;
$3 = NULL;
if ($1 &gt; 0) {
$2 = (char **) malloc($1*sizeof(char *));
$3 = (int *) malloc($1*sizeof(int));
keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
for (i = 0; i &lt; $1; i++) {
<b>key = rb_ary_entry(keys_arr, i);
val = rb_hash_aref($input, key);</b>
@ -3781,13 +3781,13 @@ value is a <tt>Fixnum</tt>: </p>
<pre>%typemap(in) (int nattributes, const char **names, const int *values)
(VALUE keys_arr, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
$2 = NULL;
$3 = NULL;
if ($1 &gt; 0) {
$2 = (char **) malloc($1*sizeof(char *));
$3 = (int *) malloc($1*sizeof(int));
keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
for (i = 0; i &lt; $1; i++) {
key = rb_ary_entry(keys_arr, i);
val = rb_hash_aref($input, key);
@ -3805,13 +3805,13 @@ equivalents and store them in our local C arrays: </p>
<pre>%typemap(in) (int nattributes, const char **names, const int *values)
(VALUE keys_arr, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
$2 = NULL;
$3 = NULL;
if ($1 &gt; 0) {
$2 = (char **) malloc($1*sizeof(char *));
$3 = (int *) malloc($1*sizeof(int));
keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
for (i = 0; i &lt; $1; i++) {
key = rb_ary_entry(keys_arr, i);
val = rb_hash_aref($input, key);

View File

@ -2,13 +2,13 @@
%typemap(in) (int nattributes, const char **names, const int *values) (VALUE keys_ary, int i, VALUE key, VALUE val) {
Check_Type($input, T_HASH);
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
$1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
$2 = NULL;
$3 = NULL;
if ($1 > 0) {
$2 = (char **) malloc($1*sizeof(char *));
$3 = (int *) malloc($1*sizeof(int));
keys_ary = rb_funcall($input, rb_intern("keys"), 0, NULL);
keys_ary = rb_funcall($input, rb_intern("keys"), 0, Qnil);
for (i = 0; i < $1; i++) {
key = rb_ary_entry(keys_ary, i);
val = rb_hash_aref($input, key);

View File

@ -3046,7 +3046,7 @@ public:
if (argc > 0) {
Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", Swig_cresult_name(), methodName, argc, args);
} else {
Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", Swig_cresult_name(), methodName);
Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, Qnil);\n", Swig_cresult_name(), methodName);
}
if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n");
}