1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
import li_boost_shared_ptr_director.*;
public class li_boost_shared_ptr_director_runme {
static {
try {
System.loadLibrary("li_boost_shared_ptr_director");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
private static void check(int got, int expected) {
if (got != expected)
throw new RuntimeException("Failed, got: " + got + " expected: " + expected);
}
public static void main(String argv[]) {
li_boost_shared_ptr_director_Derived a = new li_boost_shared_ptr_director_Derived(false);
li_boost_shared_ptr_director_Derived b = new li_boost_shared_ptr_director_Derived(true);
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(a), 1);
check(li_boost_shared_ptr_director.call_ret_c_shared_ptr(b), -1);
check(li_boost_shared_ptr_director.call_ret_c_by_value(a), 1);
check(li_boost_shared_ptr_director.call_take_c_by_value(a), 5);
check(li_boost_shared_ptr_director.call_take_c_by_ref(a), 6);
check(li_boost_shared_ptr_director.call_take_c_by_pointer(a), 7);
check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref(a), 8);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value(a), 9);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref(a), 10);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer(a), 11);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref(a), 12);
check(li_boost_shared_ptr_director.call_take_c_by_pointer_with_null(a), -2);
check(li_boost_shared_ptr_director.call_take_c_by_pointer_ref_with_null(a), -3);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_value_with_null(a), -4);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_ref_with_null(a), -5);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_with_null(a), -6);
check(li_boost_shared_ptr_director.call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7);
}
}
class li_boost_shared_ptr_director_Derived extends Base {
private boolean return_none;
li_boost_shared_ptr_director_Derived(boolean flag) {
super();
this.return_none = flag;
}
@Override
public C ret_c_shared_ptr() {
if (this.return_none)
return null;
else
return new C();
}
@Override
public C ret_c_by_value() {
return new C();
}
@Override
public int take_c_by_value(C c) {
return c.get_m();
}
@Override
public int take_c_by_ref(C c) {
return c.get_m();
}
@Override
public int take_c_by_pointer(C c) {
if (c != null)
return c.get_m();
else
return -2;
}
@Override
public int take_c_by_pointer_ref(C c) {
if (c != null)
return c.get_m();
else
return -3;
}
@Override
public int take_c_shared_ptr_by_value(C c) {
if (c != null)
return c.get_m();
else
return -4;
}
@Override
public int take_c_shared_ptr_by_ref(C c) {
if (c != null)
return c.get_m();
else
return -5;
}
@Override
public int take_c_shared_ptr_by_pointer(C c) {
if (c != null)
return c.get_m();
else
return -6;
}
@Override
public int take_c_shared_ptr_by_pointer_ref(C c) {
if (c != null)
return c.get_m();
else
return -7;
}
}
|