Merge branch 'typecheck-null-nonpointers'
* typecheck-null-nonpointers: Fix overloading for non-pointers and NULL - MzScheme Overloading for non-pointers and NULL - Chicken Fix overloading for non-pointers and NULL - Scilab Fix overloading for non-pointers and NULL - R Fix overloading for non-pointers and NULL - Php Fix overloading for non-pointers and NULL - Octave Fix overloading for non-pointers and NULL - Lua Overloading for non-pointers and NULL - Javascript Fix overloading for non-pointers and NULL - Guile Fix overloading for non-pointers and NULL - Tcl Fix overloading for non-pointers and NULL - Perl Fix overloading for non-pointers and NULL - Ruby Add test for overloading and NULL Correct Python implicitconv code Fix typecheck typemaps for non-pointers and NULL
This commit is contained in:
commit
6a80ec314a
40 changed files with 685 additions and 87 deletions
|
|
@ -340,6 +340,7 @@ CPP_TEST_CASES += \
|
|||
overload_extend \
|
||||
overload_method \
|
||||
overload_numeric \
|
||||
overload_null \
|
||||
overload_polymorphic \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
|
|
|
|||
53
Examples/test-suite/guile/overload_null_runme.scm
Normal file
53
Examples/test-suite/guile/overload_null_runme.scm
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_null_module" (dynamic-link "./liboverload_null"))
|
||||
|
||||
(define-macro (check form)
|
||||
`(if (not ,form)
|
||||
(error "Check failed: " ',form)))
|
||||
|
||||
(define (=~ a b)
|
||||
(< (abs (- a b)) 1e-8))
|
||||
|
||||
(define o (new-Overload))
|
||||
(define x (new-X))
|
||||
|
||||
(check (=~ 1 (Overload-byval1 o x)))
|
||||
(check (=~ 2 (Overload-byval1 o #nil)))
|
||||
|
||||
(check (=~ 3 (Overload-byval2 o #nil)))
|
||||
(check (=~ 4 (Overload-byval2 o x)))
|
||||
|
||||
(check (=~ 5 (Overload-byref1 o x)))
|
||||
(check (=~ 6 (Overload-byref1 o #nil)))
|
||||
|
||||
(check (=~ 7 (Overload-byref2 o #nil)))
|
||||
(check (=~ 8 (Overload-byref2 o x)))
|
||||
|
||||
(check (=~ 9 (Overload-byconstref1 o x)))
|
||||
(check (=~ 10 (Overload-byconstref1 o #nil)))
|
||||
|
||||
(check (=~ 11 (Overload-byconstref2 o #nil)))
|
||||
(check (=~ 12 (Overload-byconstref2 o x)))
|
||||
|
||||
; const pointer references
|
||||
; No SWIGTYPE *const& typemaps for Guile yet
|
||||
;(check (=~ 13 (Overload-byval1cpr o x)))
|
||||
;(check (=~ 14 (Overload-byval1cpr o #nil)))
|
||||
|
||||
;(check (=~ 15 (Overload-byval2cpr o #nil)))
|
||||
;(check (=~ 16 (Overload-byval2cpr o x)))
|
||||
|
||||
; forward class declaration
|
||||
(check (=~ 17 (Overload-byval1forwardptr o x)))
|
||||
(check (=~ 18 (Overload-byval1forwardptr o #nil)))
|
||||
|
||||
(check (=~ 19 (Overload-byval2forwardptr o #nil)))
|
||||
(check (=~ 20 (Overload-byval2forwardptr o x)))
|
||||
|
||||
(check (=~ 21 (Overload-byval1forwardref o x)))
|
||||
|
||||
(check (=~ 22 (Overload-byval2forwardref o x)))
|
||||
|
||||
(exit 0)
|
||||
49
Examples/test-suite/javascript/overload_null_runme.js
Normal file
49
Examples/test-suite/javascript/overload_null_runme.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// There are no typecheck typemaps in Javascript yet, so most of this test
|
||||
// does not actually worked - the check functions have thus been commented out.
|
||||
var overload_null = require("overload_null");
|
||||
|
||||
var check = function(expected, actual) {
|
||||
if (expected !== actual) {
|
||||
throw new Error(a + " does not equal " + b);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var o = new overload_null.Overload();
|
||||
var x = new overload_null.X();
|
||||
|
||||
check(1, o.byval1(x));
|
||||
// check(2, o.byval1(null));
|
||||
|
||||
// check(3, o.byval2(null));
|
||||
check(4, o.byval2(x));
|
||||
|
||||
check(5, o.byref1(x));
|
||||
// check(6, o.byref1(null));
|
||||
|
||||
// check(7, o.byref2(null));
|
||||
check(8, o.byref2(x));
|
||||
|
||||
check(9, o.byconstref1(x));
|
||||
// check(10, o.byconstref1(null));
|
||||
|
||||
// check(11, o.byconstref2(null));
|
||||
check(12, o.byconstref2(x));
|
||||
|
||||
// const pointer references
|
||||
check(13, o.byval1cpr(x));
|
||||
// check(14, o.byval1cpr(null));
|
||||
|
||||
// check(15, o.byval2cpr(null));
|
||||
check(16, o.byval2cpr(x));
|
||||
|
||||
// forward class declaration
|
||||
check(17, o.byval1forwardptr(x));
|
||||
// check(18, o.byval1forwardptr(null));
|
||||
|
||||
// check(19, o.byval2forwardptr(null));
|
||||
check(20, o.byval2forwardptr(x));
|
||||
|
||||
check(21, o.byval1forwardref(x));
|
||||
|
||||
check(22, o.byval2forwardref(x));
|
||||
41
Examples/test-suite/lua/overload_null_runme.lua
Normal file
41
Examples/test-suite/lua/overload_null_runme.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
require("import") -- the import fn
|
||||
import("overload_null") -- import lib into global
|
||||
|
||||
o = overload_null.Overload()
|
||||
x = overload_null.X()
|
||||
|
||||
assert(1 == o:byval1(x))
|
||||
assert(2 == o:byval1(nil))
|
||||
|
||||
assert(3 == o:byval2(nil))
|
||||
assert(4 == o:byval2(x))
|
||||
|
||||
assert(5 == o:byref1(x))
|
||||
assert(6 == o:byref1(nil))
|
||||
|
||||
assert(7 == o:byref2(nil))
|
||||
assert(8 == o:byref2(x))
|
||||
|
||||
assert(9 == o:byconstref1(x))
|
||||
assert(10 == o:byconstref1(nil))
|
||||
|
||||
assert(11 == o:byconstref2(nil))
|
||||
assert(12 == o:byconstref2(x))
|
||||
|
||||
-- const pointer references
|
||||
assert(13 == o:byval1cpr(x))
|
||||
assert(14 == o:byval1cpr(nil))
|
||||
|
||||
assert(15 == o:byval2cpr(nil))
|
||||
assert(16 == o:byval2cpr(x))
|
||||
|
||||
-- forward class declaration
|
||||
assert(17 == o:byval1forwardptr(x))
|
||||
assert(18 == o:byval1forwardptr(nil))
|
||||
|
||||
assert(19 == o:byval2forwardptr(nil))
|
||||
assert(20 == o:byval2forwardptr(x))
|
||||
|
||||
assert(21 == o:byval1forwardref(x))
|
||||
|
||||
assert(22 == o:byval2forwardref(x))
|
||||
52
Examples/test-suite/octave/overload_null_runme.m
Normal file
52
Examples/test-suite/octave/overload_null_runme.m
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# do not dump Octave core
|
||||
if exist("crash_dumps_octave_core", "builtin")
|
||||
crash_dumps_octave_core(0);
|
||||
endif
|
||||
|
||||
overload_null
|
||||
|
||||
function check(a, b)
|
||||
if (a != b)
|
||||
error("%i does not equal %i", a, b);
|
||||
endif
|
||||
end
|
||||
|
||||
o = Overload();
|
||||
x = X();
|
||||
null = []; # NULL pointer
|
||||
|
||||
check(1, o.byval1(x));
|
||||
check(2, o.byval1(null));
|
||||
|
||||
check(3, o.byval2(null));
|
||||
check(4, o.byval2(x));
|
||||
|
||||
check(5, o.byref1(x));
|
||||
check(6, o.byref1(null));
|
||||
|
||||
check(7, o.byref2(null));
|
||||
check(8, o.byref2(x));
|
||||
|
||||
check(9, o.byconstref1(x));
|
||||
check(10, o.byconstref1(null));
|
||||
|
||||
check(11, o.byconstref2(null));
|
||||
check(12, o.byconstref2(x));
|
||||
|
||||
# const pointer references
|
||||
check(13, o.byval1cpr(x));
|
||||
check(14, o.byval1cpr(null));
|
||||
|
||||
check(15, o.byval2cpr(null));
|
||||
check(16, o.byval2cpr(x));
|
||||
|
||||
# forward class declaration
|
||||
check(17, o.byval1forwardptr(x));
|
||||
check(18, o.byval1forwardptr(null));
|
||||
|
||||
check(19, o.byval2forwardptr(null));
|
||||
check(20, o.byval2forwardptr(x));
|
||||
|
||||
check(21, o.byval1forwardref(x));
|
||||
|
||||
check(22, o.byval2forwardref(x));
|
||||
52
Examples/test-suite/overload_null.i
Normal file
52
Examples/test-suite/overload_null.i
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
%module overload_null
|
||||
|
||||
%{
|
||||
struct F {};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct X {};
|
||||
struct Y {};
|
||||
struct F;
|
||||
|
||||
struct Overload {
|
||||
int byval1(X x) { return 1; }
|
||||
int byval1(Y* y) { return 2; }
|
||||
|
||||
int byval2(Y* y) { return 3; }
|
||||
int byval2(X x) { return 4; }
|
||||
|
||||
int byref1(X& x) { return 5; }
|
||||
int byref1(Y* y) { return 6; }
|
||||
|
||||
int byref2(Y* y) { return 7; }
|
||||
int byref2(X& x) { return 8; }
|
||||
|
||||
int byconstref1(const X& x) { return 9; }
|
||||
int byconstref1(Y* y) { return 10; }
|
||||
|
||||
int byconstref2(Y* y) { return 11; }
|
||||
int byconstref2(const X& x) { return 12; }
|
||||
|
||||
// const pointer references
|
||||
int byval1cpr(X x) { return 13; }
|
||||
int byval1cpr(Y*const& y) { return 14; }
|
||||
|
||||
int byval2cpr(Y*const& y) { return 15; }
|
||||
int byval2cpr(X x) { return 16; }
|
||||
|
||||
// forward class declaration
|
||||
int byval1forwardptr(X x) { return 17; }
|
||||
int byval1forwardptr(F* f) { return 18; }
|
||||
|
||||
int byval2forwardptr(F* f) { return 19; }
|
||||
int byval2forwardptr(X x) { return 20; }
|
||||
|
||||
int byval1forwardref(X x) { return 21; }
|
||||
int byval1forwardref(F& f) { return -21; }
|
||||
|
||||
int byval2forwardref(F& f) { return -22; }
|
||||
int byval2forwardref(X x) { return 22; }
|
||||
|
||||
};
|
||||
%}
|
||||
44
Examples/test-suite/perl5/overload_null_runme.pl
Normal file
44
Examples/test-suite/perl5/overload_null_runme.pl
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 24;
|
||||
BEGIN { use_ok('overload_null') }
|
||||
require_ok('overload_null');
|
||||
|
||||
my $o = new overload_null::Overload();
|
||||
my $x = new overload_null::X();
|
||||
|
||||
is(1, $o->byval1($x));
|
||||
is(2, $o->byval1(undef));
|
||||
|
||||
is(3, $o->byval2(undef));
|
||||
is(4, $o->byval2($x));
|
||||
|
||||
is(5, $o->byref1($x));
|
||||
is(6, $o->byref1(undef));
|
||||
|
||||
is(7, $o->byref2(undef));
|
||||
is(8, $o->byref2($x));
|
||||
|
||||
is(9, $o->byconstref1($x));
|
||||
is(10, $o->byconstref1(undef));
|
||||
|
||||
is(11, $o->byconstref2(undef));
|
||||
is(12, $o->byconstref2($x));
|
||||
|
||||
# const pointer references
|
||||
is(13, $o->byval1cpr($x));
|
||||
is(14, $o->byval1cpr(undef));
|
||||
|
||||
is(15, $o->byval2cpr(undef));
|
||||
is(16, $o->byval2cpr($x));
|
||||
|
||||
# forward class declaration
|
||||
is(17, $o->byval1forwardptr($x));
|
||||
is(18, $o->byval1forwardptr(undef));
|
||||
|
||||
is(19, $o->byval2forwardptr(undef));
|
||||
is(20, $o->byval2forwardptr($x));
|
||||
|
||||
is(21, $o->byval1forwardref($x));
|
||||
|
||||
is(22, $o->byval2forwardref($x));
|
||||
46
Examples/test-suite/php/overload_null_runme.php
Normal file
46
Examples/test-suite/php/overload_null_runme.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_null.php";
|
||||
|
||||
$o = new Overload();
|
||||
$x = new X();
|
||||
|
||||
check::equal(1, $o->byval1($x), "test 1");
|
||||
check::equal(2, $o->byval1(null), "test 2");
|
||||
|
||||
check::equal(3, $o->byval2(null), "test 3");
|
||||
check::equal(4, $o->byval2($x), "test 4");
|
||||
|
||||
check::equal(5, $o->byref1($x), "test 5");
|
||||
check::equal(6, $o->byref1(null), "test 6");
|
||||
|
||||
check::equal(7, $o->byref2(null), "test 7");
|
||||
check::equal(8, $o->byref2($x), "test 8");
|
||||
|
||||
check::equal(9, $o->byconstref1($x), "test 9");
|
||||
check::equal(10, $o->byconstref1(null), "test 10");
|
||||
|
||||
check::equal(11, $o->byconstref2(null), "test 11");
|
||||
check::equal(12, $o->byconstref2($x), "test 12");
|
||||
|
||||
# const pointer references
|
||||
check::equal(13, $o->byval1cpr($x), "test 13");
|
||||
check::equal(14, $o->byval1cpr(null), "test 14");
|
||||
|
||||
check::equal(15, $o->byval2cpr(null), "test 15");
|
||||
check::equal(16, $o->byval2cpr($x), "test 16");
|
||||
|
||||
# forward class declaration
|
||||
check::equal(17, $o->byval1forwardptr($x), "test 17");
|
||||
check::equal(18, $o->byval1forwardptr(null), "test 18");
|
||||
|
||||
check::equal(19, $o->byval2forwardptr(null), "test 19");
|
||||
check::equal(20, $o->byval2forwardptr($x), "test 20");
|
||||
|
||||
check::equal(21, $o->byval1forwardref($x), "test 21");
|
||||
|
||||
check::equal(22, $o->byval2forwardref($x), "test 22");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -13,15 +13,7 @@ check(1, A(1).get())
|
|||
check(2, A(1.0).get())
|
||||
check(3, A(B()).get())
|
||||
check(4, A("hello").get())
|
||||
try:
|
||||
check(3, A(None).get())
|
||||
raise RuntimeError
|
||||
except ValueError:
|
||||
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
||||
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
||||
# references and pointers to different types, where pointers ought to be
|
||||
# given a slightly higher precedence.
|
||||
pass
|
||||
check(4, A(None).get())
|
||||
|
||||
check(1, get(1))
|
||||
check(2, get(1.0))
|
||||
|
|
|
|||
44
Examples/test-suite/python/overload_null_runme.py
Normal file
44
Examples/test-suite/python/overload_null_runme.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from overload_null import *
|
||||
|
||||
def check(a, b):
|
||||
if a != b:
|
||||
raise RuntimeError(str(a) + " does not equal " + str(b))
|
||||
|
||||
o = Overload()
|
||||
x = X()
|
||||
|
||||
check(1, o.byval1(x))
|
||||
check(2, o.byval1(None))
|
||||
|
||||
check(3, o.byval2(None))
|
||||
check(4, o.byval2(x))
|
||||
|
||||
check(5, o.byref1(x))
|
||||
check(6, o.byref1(None))
|
||||
|
||||
check(7, o.byref2(None))
|
||||
check(8, o.byref2(x))
|
||||
|
||||
check(9, o.byconstref1(x))
|
||||
check(10, o.byconstref1(None))
|
||||
|
||||
check(11, o.byconstref2(None))
|
||||
check(12, o.byconstref2(x))
|
||||
|
||||
# const pointer references
|
||||
check(13, o.byval1cpr(x))
|
||||
check(14, o.byval1cpr(None))
|
||||
|
||||
check(15, o.byval2cpr(None))
|
||||
check(16, o.byval2cpr(x))
|
||||
|
||||
# forward class declaration
|
||||
check(17, o.byval1forwardptr(x))
|
||||
check(18, o.byval1forwardptr(None))
|
||||
|
||||
check(19, o.byval2forwardptr(None))
|
||||
check(20, o.byval2forwardptr(x))
|
||||
|
||||
check(21, o.byval1forwardref(x))
|
||||
|
||||
check(22, o.byval2forwardref(x))
|
||||
49
Examples/test-suite/r/overload_null_runme.R
Normal file
49
Examples/test-suite/r/overload_null_runme.R
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
|
||||
dyn.load(paste("overload_null", .Platform$dynlib.ext, sep=""))
|
||||
source("overload_null.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
o <- Overload()
|
||||
x <- X()
|
||||
|
||||
unittest(1, o$byval1(x))
|
||||
unittest(2, o$byval1(NULL))
|
||||
|
||||
unittest(3, o$byval2(NULL))
|
||||
unittest(4, o$byval2(x))
|
||||
|
||||
unittest(5, o$byref1(x))
|
||||
unittest(6, o$byref1(NULL))
|
||||
|
||||
unittest(7, o$byref2(NULL))
|
||||
unittest(8, o$byref2(x))
|
||||
|
||||
unittest(9, o$byconstref1(x))
|
||||
unittest(10, o$byconstref1(NULL))
|
||||
|
||||
unittest(11, o$byconstref2(NULL))
|
||||
unittest(12, o$byconstref2(x))
|
||||
|
||||
# const pointer references
|
||||
# No SWIGTYPE *const& typemaps for R yet
|
||||
#unittest(13, o$byval1cpr(x))
|
||||
#unittest(14, o$byval1cpr(NULL))
|
||||
|
||||
#unittest(15, o$byval2cpr(NULL))
|
||||
#unittest(16, o$byval2cpr(x))
|
||||
|
||||
# forward class declaration
|
||||
unittest(17, o$byval1forwardptr(x))
|
||||
unittest(18, o$byval1forwardptr(NULL))
|
||||
|
||||
unittest(19, o$byval2forwardptr(NULL))
|
||||
unittest(20, o$byval2forwardptr(x))
|
||||
|
||||
unittest(21, o$byval1forwardref(x))
|
||||
|
||||
unittest(22, o$byval2forwardref(x))
|
||||
|
||||
q(save="no")
|
||||
|
||||
52
Examples/test-suite/ruby/overload_null_runme.rb
Normal file
52
Examples/test-suite/ruby/overload_null_runme.rb
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'overload_null'
|
||||
|
||||
include Overload_null
|
||||
|
||||
o = Overload.new
|
||||
x = X.new
|
||||
|
||||
swig_assert(1 == o.byval1(x))
|
||||
swig_assert(2 == o.byval1(nil))
|
||||
|
||||
swig_assert(3 == o.byval2(nil))
|
||||
swig_assert(4 == o.byval2(x))
|
||||
|
||||
swig_assert(5 == o.byref1(x))
|
||||
swig_assert(6 == o.byref1(nil))
|
||||
|
||||
swig_assert(7 == o.byref2(nil))
|
||||
swig_assert(8 == o.byref2(x))
|
||||
|
||||
swig_assert(9 == o.byconstref1(x))
|
||||
swig_assert(10 == o.byconstref1(nil))
|
||||
|
||||
swig_assert(11 == o.byconstref2(nil))
|
||||
swig_assert(12 == o.byconstref2(x))
|
||||
|
||||
# const pointer references
|
||||
swig_assert(13 == o.byval1cpr(x))
|
||||
swig_assert(14 == o.byval1cpr(nil))
|
||||
|
||||
swig_assert(15 == o.byval2cpr(nil))
|
||||
swig_assert(16 == o.byval2cpr(x))
|
||||
|
||||
# forward class declaration
|
||||
swig_assert(17 == o.byval1forwardptr(x))
|
||||
swig_assert(18 == o.byval1forwardptr(nil))
|
||||
|
||||
swig_assert(19 == o.byval2forwardptr(nil))
|
||||
swig_assert(20 == o.byval2forwardptr(x))
|
||||
|
||||
swig_assert(21 == o.byval1forwardref(x))
|
||||
|
||||
swig_assert(22 == o.byval2forwardref(x))
|
||||
45
Examples/test-suite/scilab/overload_null_runme.sci
Normal file
45
Examples/test-suite/scilab/overload_null_runme.sci
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
NULL = SWIG_ptr(0);
|
||||
|
||||
o = new_Overload();
|
||||
x = new_X();
|
||||
|
||||
checkequal(1, Overload_byval1(o, x), "test 1");
|
||||
checkequal(2, Overload_byval1(o, NULL), "test 2");
|
||||
|
||||
checkequal(3, Overload_byval2(o, NULL), "test 3");
|
||||
checkequal(4, Overload_byval2(o, x), "test 4");
|
||||
|
||||
checkequal(5, Overload_byref1(o, x), "test 5");
|
||||
checkequal(6, Overload_byref1(o, NULL), "test 6");
|
||||
|
||||
checkequal(7, Overload_byref2(o, NULL), "test 7");
|
||||
checkequal(8, Overload_byref2(o, x), "test 8");
|
||||
|
||||
checkequal(9, Overload_byconstref1(o, x), "test 9");
|
||||
checkequal(10, Overload_byconstref1(o, NULL), "test 10");
|
||||
|
||||
checkequal(11, Overload_byconstref2(o, NULL), "test 11");
|
||||
checkequal(12, Overload_byconstref2(o, x), "test 12");
|
||||
|
||||
// const pointer references
|
||||
checkequal(13, Overload_byval1cpr(o, x), "test 13");
|
||||
checkequal(14, Overload_byval1cpr(o, NULL), "test 14");
|
||||
|
||||
checkequal(15, Overload_byval2cpr(o, NULL), "test 15");
|
||||
checkequal(16, Overload_byval2cpr(o, x), "test 16");
|
||||
|
||||
// forward class declaration
|
||||
checkequal(17, Overload_byval1forwardptr(o, x), "test 17");
|
||||
checkequal(18, Overload_byval1forwardptr(o, NULL), "test 18");
|
||||
|
||||
checkequal(19, Overload_byval2forwardptr(o, NULL), "test 19");
|
||||
checkequal(20, Overload_byval2forwardptr(o, x), "test 20");
|
||||
|
||||
checkequal(21, Overload_byval1forwardref(o, x), "test 21");
|
||||
|
||||
checkequal(22, Overload_byval2forwardref(o, x), "test 22");
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
|
||||
52
Examples/test-suite/tcl/overload_null_runme.tcl
Normal file
52
Examples/test-suite/tcl/overload_null_runme.tcl
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
if [ catch { load ./overload_null[info sharedlibextension] overload_null} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
}
|
||||
|
||||
proc check {what expected actual} {
|
||||
if {$expected != $actual } {
|
||||
error "Failed: $what Expected: $expected , Actual: $actual"
|
||||
}
|
||||
}
|
||||
|
||||
set o [Overload]
|
||||
set x [X]
|
||||
|
||||
check "test1 " 1 [$o byval1 $x]
|
||||
check "test2 " 2 [$o byval1 "NULL"]
|
||||
|
||||
check "testX" 1 [$o byval1 $x]
|
||||
check "testX" 2 [$o byval1 "NULL"]
|
||||
|
||||
check "testX" 3 [$o byval2 "NULL"]
|
||||
check "testX" 4 [$o byval2 $x]
|
||||
|
||||
check "testX" 5 [$o byref1 $x]
|
||||
check "testX" 6 [$o byref1 "NULL"]
|
||||
|
||||
check "testX" 7 [$o byref2 "NULL"]
|
||||
check "testX" 8 [$o byref2 $x]
|
||||
|
||||
check "testX" 9 [$o byconstref1 $x]
|
||||
check "testX" 10 [$o byconstref1 "NULL"]
|
||||
|
||||
check "testX" 11 [$o byconstref2 "NULL"]
|
||||
check "testX" 12 [$o byconstref2 $x]
|
||||
|
||||
# const pointer references
|
||||
check "testX" 13 [$o byval1cpr $x]
|
||||
check "testX" 14 [$o byval1cpr "NULL"]
|
||||
|
||||
check "testX" 15 [$o byval2cpr "NULL"]
|
||||
check "testX" 16 [$o byval2cpr $x]
|
||||
|
||||
# forward class declaration
|
||||
check "testX" 17 [$o byval1forwardptr $x]
|
||||
check "testX" 18 [$o byval1forwardptr "NULL"]
|
||||
|
||||
check "testX" 19 [$o byval2forwardptr "NULL"]
|
||||
check "testX" 20 [$o byval2forwardptr $x]
|
||||
|
||||
check "testX" 21 [$o byval1forwardref $x]
|
||||
|
||||
check "testX" 22 [$o byval2forwardref $x]
|
||||
|
|
@ -11,8 +11,9 @@
|
|||
#include <chicken.h>
|
||||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; // Common C API type-checking code
|
||||
%insert(runtime) "chickenrun.swg"; // CHICKEN run-time code
|
||||
%insert(runtime) "swigrun.swg" // Common C API type-checking code
|
||||
%insert(runtime) "swigerrors.swg" // SWIG errors
|
||||
%insert(runtime) "chickenrun.swg" // CHICKEN run-time code
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* standard typemaps
|
||||
|
|
@ -617,7 +618,7 @@ $result = C_SCHEME_UNDEFINED;
|
|||
$1 = C_swig_is_string ($input);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] {
|
||||
void *ptr;
|
||||
$1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
|
||||
}
|
||||
|
|
@ -630,33 +631,30 @@ $result = C_SCHEME_UNDEFINED;
|
|||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &
|
||||
{
|
||||
void *ptr = 0;
|
||||
if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) {
|
||||
/* error */
|
||||
if (SWIG_ConvertPtr($input, &ptr, $descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = (ptr != 0);
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &&
|
||||
{
|
||||
void *ptr = 0;
|
||||
if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) {
|
||||
/* error */
|
||||
if (SWIG_ConvertPtr($input, &ptr, $descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = (ptr != 0);
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
|
||||
{
|
||||
void *ptr = 0;
|
||||
if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) {
|
||||
/* error */
|
||||
if (SWIG_ConvertPtr($input, &ptr, $&descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = (ptr != 0);
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags
|
|||
|
||||
if (s == C_SCHEME_FALSE) {
|
||||
*result = NULL;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
} else if (C_swig_is_swigpointer(s)) {
|
||||
/* try and convert type */
|
||||
from = (swig_type_info *) C_block_item(s, 1);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define SWIGGUILE_SCM
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
|
||||
%runtime "guile_scm_run.swg"
|
||||
%include <guile.i>
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
|
|||
|
||||
if (SCM_NULLP(smob)) {
|
||||
*result = NULL;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
#if SCM_MAJOR_VERSION >= 2
|
||||
} else if (SCM_POINTER_P(s)) {
|
||||
*result = SCM_POINTER_VALUE(s);
|
||||
|
|
|
|||
|
|
@ -444,15 +444,21 @@ typedef unsigned long SCM;
|
|||
$1 = scm_is_string($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] {
|
||||
void *ptr;
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &, SWIGTYPE && {
|
||||
void *ptr;
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, voi
|
|||
/* special case: JavaScript null => C NULL pointer */
|
||||
if(JSValueIsNull(context, valRef)) {
|
||||
*ptr=0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
|
||||
if(!JSValueIsObject(context, valRef)) {
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swi
|
|||
/* special case: JavaScript null => C NULL pointer */
|
||||
if(valRef->IsNull()) {
|
||||
*ptr=0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
if(!valRef->IsObject()) {
|
||||
return SWIG_TypeError;
|
||||
|
|
|
|||
|
|
@ -1765,7 +1765,12 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
|
|||
{
|
||||
swig_lua_userdata *usr;
|
||||
swig_cast_info *cast;
|
||||
if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */
|
||||
/* special case: lua nil => NULL pointer */
|
||||
if (lua_isnil(L,index))
|
||||
{
|
||||
*ptr=0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */
|
||||
if (usr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
* all the runtime code for .
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg"; /* Common C API type-checking code */
|
||||
%runtime "luarun.swg"; /* Lua runtime stuff */
|
||||
%runtime "swigrun.swg" /* Common C API type-checking code */
|
||||
%runtime "swigerrors.swg" /* SWIG errors */
|
||||
%runtime "luarun.swg" /* Lua runtime stuff */
|
||||
|
||||
%insert(initbeforefunc) "swiginit.swg"
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
|
|||
// Also needed for object ptrs by const ref
|
||||
// eg A* const& ref_pointer(A* const& a);
|
||||
// found in mixed_types.i
|
||||
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp)
|
||||
%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE *const&($*ltype temp)
|
||||
%{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname");
|
||||
$1=($1_ltype)&temp;%}
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ parameters match which function
|
|||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & {
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) {
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
|
@ -336,7 +336,7 @@ parameters match which function
|
|||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && {
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) {
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
|
@ -345,7 +345,7 @@ parameters match which function
|
|||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) {
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
|
@ -367,7 +367,7 @@ parameters match which function
|
|||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
|
||||
{
|
||||
void *ptr;
|
||||
if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) {
|
||||
if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type,
|
|||
|
||||
if (SCHEME_NULLP(s)) {
|
||||
*result = NULL;
|
||||
return 0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
} else if (SCHEME_TYPE(s) == swig_type) {
|
||||
struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) s;
|
||||
if (type) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
/* Include headers */
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
%runtime "mzrun.swg"
|
||||
|
||||
%define SWIG_APPEND_VALUE(value)
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
|
|||
$1 = (SCHEME_STRINGP($input)) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) {
|
||||
$1 = 0;
|
||||
|
|
@ -338,9 +338,18 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
|
|||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &, SWIGTYPE && {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
|
||||
void *ptr;
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0)) {
|
||||
if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL)) {
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = 1;
|
||||
|
|
|
|||
|
|
@ -1477,7 +1477,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_t
|
|||
(ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
if (ov.type_id() != octave_swig_ref::static_type_id())
|
||||
return SWIG_ERROR;
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_
|
|||
voidptr = INT2PTR(void *,tmp);
|
||||
} else if (! SvOK(sv)) { /* Check for undef */
|
||||
*(ptr) = (void *) 0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
} else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */
|
||||
if (!SvROK(sv)) {
|
||||
/* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value. */
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
%runtime "phprun.swg" // PHP runtime functions
|
||||
|
||||
%include <phpinit.swg> // PHP initialization routine.
|
||||
|
|
@ -470,20 +471,26 @@
|
|||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
|
||||
{
|
||||
void *tmp;
|
||||
_v = (SWIG_ConvertPtr(&$input, (void **)&tmp, $&1_descriptor, 0) >= 0);
|
||||
_v = (SWIG_ConvertPtr(&$input, (void **)&tmp, $&1_descriptor, SWIG_POINTER_NO_NULL) >= 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER)
|
||||
SWIGTYPE *,
|
||||
SWIGTYPE [],
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE &&,
|
||||
SWIGTYPE *const&
|
||||
{
|
||||
void *tmp;
|
||||
_v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, 0) >= 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER)
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE &&
|
||||
{
|
||||
void *tmp;
|
||||
_v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, SWIG_POINTER_NO_NULL) >= 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
|
||||
{
|
||||
void *tmp;
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
|
|||
return (*ptr == NULL ? -1 : 0);
|
||||
case IS_NULL:
|
||||
*ptr = 0;
|
||||
return 0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -1018,7 +1018,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
|||
if (obj == Py_None && !implicit_conv) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
|
||||
res = SWIG_ERROR;
|
||||
|
|
@ -1098,13 +1098,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!SWIG_IsOK(res) && obj == Py_None) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Clear();
|
||||
res = SWIG_OK;
|
||||
if (!SWIG_IsOK(res) && obj == Py_None) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Clear();
|
||||
res = SWIG_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
%insert("header") "swiglabels.swg"
|
||||
|
||||
%insert("header") "swigerrors.swg"
|
||||
%insert("init") "swiginit.swg"
|
||||
%insert("runtime") "swigrun.swg"
|
||||
%insert("runtime") "swigerrors.swg"
|
||||
%insert("runtime") "rrun.swg"
|
||||
|
||||
%init %{
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) {
|
|||
if (!obj) return SWIG_ERROR;
|
||||
if (obj == R_NilValue) {
|
||||
if (ptr) *ptr = NULL;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
|
||||
vptr = R_ExternalPtrAddr(obj);
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
|
|||
if (NIL_P(obj)) {
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
} else {
|
||||
if (TYPE(obj) != T_DATA) {
|
||||
return SWIG_ERROR;
|
||||
|
|
|
|||
|
|
@ -303,7 +303,10 @@ SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pvObj, swig_type_info *de
|
|||
|
||||
if (pvObj) {
|
||||
*pvObj = pvPtr;
|
||||
return SWIG_OK;
|
||||
if (pvPtr)
|
||||
return SWIG_OK;
|
||||
else
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
/* Flags for pointer conversions */
|
||||
#define SWIG_POINTER_DISOWN 0x1
|
||||
#define SWIG_CAST_NEW_MEMORY 0x2
|
||||
#define SWIG_POINTER_NO_NULL 0x4
|
||||
|
||||
/* Flags for new pointer objects */
|
||||
#define SWIG_POINTER_OWN 0x1
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swi
|
|||
/* Pointer values must start with leading underscore */
|
||||
while (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
if (strcmp(c,"NULL") == 0) return SWIG_OK;
|
||||
if (strcmp(c,"NULL") == 0)
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
|
||||
/* Empty string: not a pointer */
|
||||
if (*c == 0) return SWIG_ERROR;
|
||||
|
|
|
|||
|
|
@ -358,46 +358,46 @@
|
|||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus) && defined(%implicitconv_flag)
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & {
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag);
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && {
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag);
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE {
|
||||
int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag);
|
||||
int res = SWIG_ConvertPtr($input, 0, $&descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
#else
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE & {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, 0);
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, SWIG_POINTER_NO_NULL);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1664,37 +1664,29 @@ void R::dispatchFunction(Node *n) {
|
|||
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
|
||||
}
|
||||
Printf(f->code, "%s(%s)",
|
||||
j == 0? "" : " && ",
|
||||
j == 0 ? "" : " && ",
|
||||
tmcheck);
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
// Below should be migrated into rtypecheck typemaps
|
||||
if (tm) {
|
||||
if (Strcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else if (Strcmp(tm,"integer")==0) {
|
||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
}
|
||||
else if (Strcmp(tm,"character")==0) {
|
||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
Printf(f->code, "%s", j == 0 ? "" : " && ");
|
||||
if (Strcmp(tm, "numeric") == 0) {
|
||||
Printf(f->code, "is.numeric(argv[[%d]])", j+1);
|
||||
} else if (Strcmp(tm, "integer") == 0) {
|
||||
Printf(f->code, "(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", j+1, j+1);
|
||||
} else if (Strcmp(tm, "character") == 0) {
|
||||
Printf(f->code, "is.character(argv[[%d]])", j+1);
|
||||
} else {
|
||||
if (SwigType_ispointer(Getattr(p, "type")))
|
||||
Printf(f->code, "(extends(argtypes[%d], '%s') || is.null(argv[[%d]]))", j+1, tm, j+1);
|
||||
else
|
||||
Printf(f->code, "extends(argtypes[%d], '%s')", j+1, tm);
|
||||
}
|
||||
}
|
||||
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
||||
Printf(f->code, " && length(argv[[%d]]) == 1",
|
||||
j+1);
|
||||
Printf(f->code, " && length(argv[[%d]]) == 1", j+1);
|
||||
}
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue