Merge branch 'master' into cpp17-hexadecimal-floating-literals

This commit is contained in:
William S Fulton 2019-02-15 18:57:25 +00:00 committed by GitHub
commit b0f105fa9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
113 changed files with 1848 additions and 295 deletions

View file

@ -7,6 +7,44 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.0.0 (in progress)
===========================
2019-02-14: wsfulton
Add some missing copy constructors into STL containers.
2019-02-14: bkotzz
[Java] #1356 Add STL containers:
std::unordered_map
std::unordered_set
std::set
2019-02-14: bkotzz
[Java] #1356 std::map wrappers have been modified. Now the Java proxy class
extends java.util.AbstractMap. The std::map container looks and feels much like
a java.util.HashMap from Java.
A few members have changed their names. If the old method signatures are needed,
then copy std_map.i from swig-3.0.12 and use that instead. Alternatively,
add the old missing methods to the new methods by using the following %proxycode:
%extend std::map {
%proxycode %{
// Old API
public boolean empty() {
return isEmpty();
}
public void set($typemap(jboxtype, K) key, $typemap(jboxtype, T) x) {
put(key, x);
}
public void del($typemap(jboxtype, K) key) {
remove(key);
}
public boolean has_key($typemap(jboxtype, K) key) {
return containsKey(key);
}
%}
}
*** POTENTIAL INCOMPATIBILITY ***
2019-02-13: ZackerySpytz
#1469 Add support for C++17 hexadecimal floating literals.

View file

@ -576,7 +576,7 @@ CPP11_TEST_CASES += \
cpp11_initializer_list \
cpp11_initializer_list_extend \
cpp11_lambda_functions \
cpp11_li_std_array \
cpp11_std_array \
cpp11_noexcept \
cpp11_null_pointer_constant \
cpp11_raw_string_literals \

View file

@ -1,4 +1,4 @@
%module cpp11_li_std_array
%module cpp11_std_array
#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP)

View file

@ -1,5 +1,7 @@
%module cpp11_std_unordered_map
%include <std_string.i>
%include <std_unordered_map.i>
%template(UnorderedMapIntInt) std::unordered_map<int, int>;
%template(UnorderedMapStringInt) std::unordered_map<std::string, int>;

View file

@ -1,5 +1,7 @@
%module cpp11_std_unordered_set
%include <std_string.i>
%include <std_unordered_set.i>
%template(UnorderedSetInt) std::unordered_set<int>;
%template(UnorderedSetString) std::unordered_set<std::string>;

View file

@ -1,8 +1,8 @@
// This test tests all the methods in the C# collection wrapper
using System;
using cpp11_li_std_arrayNamespace;
using cpp11_std_arrayNamespace;
public class cpp11_li_std_array_runme
public class cpp11_std_array_runme
{
private static ArrayInt6 ToArray6(int[] a)
{
@ -37,24 +37,24 @@ public class cpp11_li_std_array_runme
compareContainers(ai, vals);
// Check return
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 });
// Check passing arguments
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
ai = cpp11_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
ai = cpp11_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
cpp11_li_std_array.arrayInRef(ai);
cpp11_std_array.arrayInRef(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
cpp11_li_std_array.arrayInPtr(ai);
cpp11_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
// fill

View file

@ -44,6 +44,8 @@ CPP_TEST_CASES = \
java_typemaps_proxy \
java_typemaps_typewrapper \
li_std_list \
li_std_map \
li_std_set \
# li_boost_intrusive_ptr
CPP11_TEST_CASES = \
@ -51,6 +53,8 @@ CPP11_TEST_CASES = \
cpp11_shared_ptr_nullptr_in_containers \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_upcast \
cpp11_std_unordered_map \
cpp11_std_unordered_set \
cpp11_strongly_typed_enumerations_simple \
DOXYGEN_TEST_CASES := \

View file

@ -1,10 +1,10 @@
import cpp11_li_std_array.*;
import cpp11_std_array.*;
public class cpp11_li_std_array_runme {
public class cpp11_std_array_runme {
static {
try {
System.loadLibrary("cpp11_li_std_array");
System.loadLibrary("cpp11_std_array");
} 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);
@ -43,24 +43,24 @@ public class cpp11_li_std_array_runme {
compareContainers(ai, vals);
// Check return
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2});
compareContainers(cpp11_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2});
// Check passing arguments
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
ai = cpp11_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
ai = cpp11_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
cpp11_li_std_array.arrayInRef(ai);
cpp11_std_array.arrayInRef(ai);
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4}));
cpp11_li_std_array.arrayInPtr(ai);
cpp11_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40});
// fill

View file

@ -0,0 +1,122 @@
import cpp11_std_unordered_map.*;
public class cpp11_std_unordered_map_runme {
static {
try {
System.loadLibrary("cpp11_std_unordered_map");
} 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);
}
}
public static void checkThat(boolean mustBeTrue) throws Throwable {
if (!mustBeTrue) {
// Index [2], since this function is one hop away from main, and [1] is the current method.
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
}
}
public static void main(String argv[]) throws Throwable
{
java.util.AbstractMap<String, Integer> sim = new UnorderedMapStringInt();
java.util.AbstractMap<Integer, Integer> iim = new UnorderedMapIntInt();
checkThat(sim.isEmpty());
checkThat(iim.isEmpty());
checkThat(sim.size() == 0);
checkThat(iim.size() == 0);
checkThat(sim.get("key") == null);
checkThat(iim.get(1) == null);
checkThat(!sim.containsKey("key"));
checkThat(!iim.containsKey(1));
checkThat(sim.put("key", 2) == null);
checkThat(iim.put(1, 2) == null);
checkThat(sim.size() == 1);
checkThat(iim.size() == 1);
checkThat(!sim.isEmpty());
checkThat(!iim.isEmpty());
checkThat(sim.get("key") == 2);
checkThat(iim.get(1) == 2);
checkThat(sim.remove("key") == 2);
checkThat(iim.remove(1) == 2);
checkThat(sim.isEmpty());
checkThat(iim.isEmpty());
checkThat(sim.size() == 0);
checkThat(iim.size() == 0);
checkThat(sim.get("key") == null);
checkThat(iim.get(1) == null);
checkThat(sim.remove("key") == null);
checkThat(iim.remove(1) == null);
checkThat(sim.put("key", 2) == null);
checkThat(iim.put(1, 2) == null);
sim.clear();
iim.clear();
checkThat(sim.isEmpty());
checkThat(iim.isEmpty());
checkThat(sim.put("key1", 1) == null);
checkThat(iim.put(1, 1) == null);
checkThat(sim.put("key2", 2) == null);
checkThat(iim.put(2, 2) == null);
checkThat(sim.size() == 2);
checkThat(iim.size() == 2);
checkThat(sim.get("key1") == 1);
checkThat(iim.get(1) == 1);
checkThat(sim.get("key2") == 2);
checkThat(iim.get(2) == 2);
checkThat(sim.put("key1", 3) == 1);
checkThat(iim.put(1, 3) == 1);
checkThat(sim.size() == 2);
checkThat(iim.size() == 2);
checkThat(sim.get("key1") == 3);
checkThat(iim.get(1) == 3);
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es = sim.entrySet();
java.util.Map<String, Integer> sim_default = new java.util.HashMap<String, Integer>();
sim_default.put("key1", 3);
sim_default.put("key2", 2);
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es_default = sim_default.entrySet();
checkThat(sim_es.size() == sim_es_default.size());
for (java.util.Map.Entry<String, Integer> entry : sim_es) {
checkThat(sim_es_default.contains(entry));
checkThat(sim_default.containsKey(entry.getKey()));
checkThat(sim_default.containsValue(entry.getValue()));
Integer oldValue = entry.getValue();
entry.setValue(oldValue + 1);
checkThat(sim.get(entry.getKey()) == (oldValue + 1));
}
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es = iim.entrySet();
java.util.Map<Integer, Integer> iim_default = new java.util.HashMap<Integer, Integer>();
iim_default.put(1, 3);
iim_default.put(2, 2);
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es_default = iim_default.entrySet();
checkThat(iim_es.size() == iim_es_default.size());
for (java.util.Map.Entry<Integer, Integer> entry : iim_es) {
checkThat(iim_es_default.contains(entry));
checkThat(iim_default.containsKey(entry.getKey()));
checkThat(iim_default.containsValue(entry.getValue()));
Integer oldValue = entry.getValue();
entry.setValue(oldValue + 1);
checkThat(iim.get(entry.getKey()) == (oldValue + 1));
}
}
}

View file

@ -0,0 +1,75 @@
import cpp11_std_unordered_set.*;
public class cpp11_std_unordered_set_runme {
static {
try {
System.loadLibrary("cpp11_std_unordered_set");
} 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);
}
}
public static void checkThat(boolean mustBeTrue) throws Throwable {
if (!mustBeTrue) {
// Index [2], since this function is one hop away from main, and [1] is the current method.
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
}
}
public static void main(String argv[]) throws Throwable
{
java.util.AbstractSet<String> ss = new UnorderedSetString();
checkThat(ss.isEmpty());
checkThat(!ss.contains("key"));
checkThat(!ss.remove("key"));
checkThat(ss.add("key"));
checkThat(!ss.add("key"));
checkThat(ss.contains("key"));
checkThat(ss.remove("key"));
checkThat(ss.isEmpty());
checkThat(ss.size() == 0);
checkThat(ss.add("key1"));
checkThat(ss.add("key2"));
checkThat(ss.add("key3"));
checkThat(ss.size() == 3);
ss.clear();
checkThat(ss.isEmpty());
checkThat(ss.size() == 0);
checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")));
checkThat(ss.size() == 3);
checkThat(ss.contains("one"));
checkThat(!ss.contains("four"));
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")));
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")));
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")));
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")));
checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")));
java.util.Set<String> found = new java.util.HashSet<String>();
java.util.Iterator<String> itr = ss.iterator();
while (itr.hasNext()) {
found.add(itr.next());
}
checkThat(ss.containsAll(found));
checkThat(found.containsAll(ss));
java.util.AbstractSet<String> ss2 = new UnorderedSetString(ss);
checkThat(ss2.containsAll(ss));
checkThat(ss.containsAll(ss2));
checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")));
checkThat(ss.removeAll(found));
checkThat(ss.isEmpty());
checkThat(ss.size() == 0);
}
}

View file

@ -0,0 +1,122 @@
import li_std_map.*;
public class li_std_map_runme {
static {
try {
System.loadLibrary("li_std_map");
} 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);
}
}
public static void checkThat(boolean mustBeTrue) throws Throwable {
if (!mustBeTrue) {
// Index [2], since this function is one hop away from main, and [1] is the current method.
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
}
}
public static void main(String argv[]) throws Throwable
{
java.util.AbstractMap<String, Integer> sim = new StringIntMap();
java.util.AbstractMap<Integer, Integer> iim = new IntIntMap();
checkThat(sim.isEmpty());
checkThat(iim.isEmpty());
checkThat(sim.size() == 0);
checkThat(iim.size() == 0);
checkThat(sim.get("key") == null);
checkThat(iim.get(1) == null);
checkThat(!sim.containsKey("key"));
checkThat(!iim.containsKey(1));
checkThat(sim.put("key", 2) == null);
checkThat(iim.put(1, 2) == null);
checkThat(sim.size() == 1);
checkThat(iim.size() == 1);
checkThat(!sim.isEmpty());
checkThat(!iim.isEmpty());
checkThat(sim.get("key") == 2);
checkThat(iim.get(1) == 2);
checkThat(sim.remove("key") == 2);
checkThat(iim.remove(1) == 2);
checkThat(sim.isEmpty());
checkThat(iim.isEmpty());
checkThat(sim.size() == 0);
checkThat(iim.size() == 0);
checkThat(sim.get("key") == null);
checkThat(iim.get(1) == null);
checkThat(sim.remove("key") == null);
checkThat(iim.remove(1) == null);
checkThat(sim.put("key", 2) == null);
checkThat(iim.put(1, 2) == null);
sim.clear();
iim.clear();
checkThat(sim.isEmpty());
checkThat(iim.isEmpty());
checkThat(sim.put("key1", 1) == null);
checkThat(iim.put(1, 1) == null);
checkThat(sim.put("key2", 2) == null);
checkThat(iim.put(2, 2) == null);
checkThat(sim.size() == 2);
checkThat(iim.size() == 2);
checkThat(sim.get("key1") == 1);
checkThat(iim.get(1) == 1);
checkThat(sim.get("key2") == 2);
checkThat(iim.get(2) == 2);
checkThat(sim.put("key1", 3) == 1);
checkThat(iim.put(1, 3) == 1);
checkThat(sim.size() == 2);
checkThat(iim.size() == 2);
checkThat(sim.get("key1") == 3);
checkThat(iim.get(1) == 3);
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es = sim.entrySet();
java.util.Map<String, Integer> sim_default = new java.util.HashMap<String, Integer>();
sim_default.put("key1", 3);
sim_default.put("key2", 2);
java.util.Set<java.util.Map.Entry<String, Integer>> sim_es_default = sim_default.entrySet();
checkThat(sim_es.size() == sim_es_default.size());
for (java.util.Map.Entry<String, Integer> entry : sim_es) {
checkThat(sim_es_default.contains(entry));
checkThat(sim_default.containsKey(entry.getKey()));
checkThat(sim_default.containsValue(entry.getValue()));
Integer oldValue = entry.getValue();
entry.setValue(oldValue + 1);
checkThat(sim.get(entry.getKey()) == (oldValue + 1));
}
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es = iim.entrySet();
java.util.Map<Integer, Integer> iim_default = new java.util.HashMap<Integer, Integer>();
iim_default.put(1, 3);
iim_default.put(2, 2);
java.util.Set<java.util.Map.Entry<Integer, Integer>> iim_es_default = iim_default.entrySet();
checkThat(iim_es.size() == iim_es_default.size());
for (java.util.Map.Entry<Integer, Integer> entry : iim_es) {
checkThat(iim_es_default.contains(entry));
checkThat(iim_default.containsKey(entry.getKey()));
checkThat(iim_default.containsValue(entry.getValue()));
Integer oldValue = entry.getValue();
entry.setValue(oldValue + 1);
checkThat(iim.get(entry.getKey()) == (oldValue + 1));
}
}
}

View file

@ -0,0 +1,75 @@
import li_std_set.*;
public class li_std_set_runme {
static {
try {
System.loadLibrary("li_std_set");
} 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);
}
}
public static void checkThat(boolean mustBeTrue) throws Throwable {
if (!mustBeTrue) {
// Index [2], since this function is one hop away from main, and [1] is the current method.
throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber());
}
}
public static void main(String argv[]) throws Throwable
{
java.util.AbstractSet<String> ss = new StringSet();
checkThat(ss.isEmpty());
checkThat(!ss.contains("key"));
checkThat(!ss.remove("key"));
checkThat(ss.add("key"));
checkThat(!ss.add("key"));
checkThat(ss.contains("key"));
checkThat(ss.remove("key"));
checkThat(ss.isEmpty());
checkThat(ss.size() == 0);
checkThat(ss.add("key1"));
checkThat(ss.add("key2"));
checkThat(ss.add("key3"));
checkThat(ss.size() == 3);
ss.clear();
checkThat(ss.isEmpty());
checkThat(ss.size() == 0);
checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")));
checkThat(ss.size() == 3);
checkThat(ss.contains("one"));
checkThat(!ss.contains("four"));
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")));
checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")));
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")));
checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")));
checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")));
java.util.Set<String> found = new java.util.HashSet<String>();
java.util.Iterator<String> itr = ss.iterator();
while (itr.hasNext()) {
found.add(itr.next());
}
checkThat(ss.containsAll(found));
checkThat(found.containsAll(ss));
java.util.AbstractSet<String> ss2 = new StringSet(ss);
checkThat(ss2.containsAll(ss));
checkThat(ss.containsAll(ss2));
checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")));
checkThat(ss.removeAll(found));
checkThat(ss.isEmpty());
checkThat(ss.size() == 0);
}
}

View file

@ -1,5 +1,5 @@
/*
* a test of set containers.
* a test of set containers.
* Languages should define swig::LANGUAGE_OBJ to be
* an entity of their native pointer type which can be
* included in a STL container.
@ -13,22 +13,23 @@
%include <std_string.i>
%include <std_set.i>
%include <std_multiset.i>
%include <std_vector.i>
%template(set_string) std::set<std::string>;
%template(set_int) std::multiset<int>;
%template(v_int) std::vector<int>;
// Use language macros since Java doesn't have multiset support (yet)
// and uses different naming conventions.
#if defined(SWIGRUBY) || defined(SWIGPYTHON)
%include <std_multiset.i>
%template(set_int) std::multiset<int>;
%template(v_int) std::vector<int>;
%template(set_string) std::set<std::string>;
#elif defined(SWIGJAVA)
%template(StringSet) std::set<std::string>;
#endif
#if defined(SWIGRUBY)
%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
#endif
#if defined(SWIGPYTHON)
%template(pyset) std::set<swig::SwigPtr_PyObject>;
%template(pyset) std::set<swig::SwigPtr_PyObject>;
#endif

View file

@ -129,6 +129,7 @@ std::vector<std::string> vecStr(std::vector<std::string> v) {
double *makeDoublePtr(double v) { return new double(v); }
int extractInt(int *p) { return *p; }
short extractConstShort(const short *p) { return *p; }
short extractConstShort2(std::vector<const short *>::value_type p) { return *p; }
%}
%template(pyvector) std::vector<swig::SwigPtr_PyObject>;

View file

@ -15,6 +15,19 @@ using namespace std;
int* makeIntPtr(int v) {
return new int(v);
}
std::vector<int *>::value_type makeIntPtr2(int v) {
return new int(v);
}
int getIntValue(int *p) {
return *p;
}
int getIntValue2(std::vector<int *>::const_reference p) {
return *p;
}
int getIntValue3(std::vector<int *>::reference p) {
return *p;
}
double* makeDoublePtr(double v) {
return new double(v);
}

View file

@ -1,4 +1,4 @@
from cpp11_li_std_array import *
from cpp11_std_array import *
import sys

View file

@ -173,3 +173,11 @@ if extractConstShort(vcs[0]) != 111:
if extractConstShort(vcs[1]) != 222:
raise RuntimeError
for p in vcs[0:1]:
if extractConstShort2(p) != 111:
raise RuntimeError
for p in vcs[1:2]:
if extractConstShort2(p) != 222:
raise RuntimeError

View file

@ -4,12 +4,20 @@ def check(val1, val2):
if val1 != val2:
raise RuntimeError("Values are not the same %s %s" % (val1, val2))
ip1 = makeIntPtr(11)
ip2 = makeIntPtr(22)
ip2 = makeIntPtr2(22)
vi = IntPtrVector((ip1, ip2))
check(getValueFromVector(vi, 0), 11)
check(getValueFromVector(vi, 1), 22)
check(getIntValue(vi[0]), 11)
check(getIntValue(vi[1]), 22)
check(getIntValue2(vi[0]), 11)
check(getIntValue2(vi[1]), 22)
ipp = makeIntPtrPtr(vi[0])
check(getIntValue3(ipp), 11) # Note: getIntValue3 takes int**
vA = APtrVector([makeA(33), makeA(34)])
check(getVectorValueA(vA, 0), 33)

View file

@ -9,9 +9,9 @@
require 'swig_assert'
require 'cpp11_li_std_array'
require 'cpp11_std_array'
include Cpp11_li_std_array
include Cpp11_std_array
def failed(a, b, msg)

View file

@ -28,17 +28,20 @@ namespace std{
template<class T> class list
{
public:
typedef T &reference;
typedef const T& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef T &iterator;
typedef const T& const_iterator;
list();
list(unsigned int size, const T& value = T());
list(const list<T> &);
list(const list& other);
~list();
void assign(unsigned int n, const T& value);
void swap(list<T> &x);
@ -46,21 +49,20 @@ namespace std{
const_reference back();
const_iterator begin();
const_iterator end();
void resize(unsigned int n, T c = T());
bool empty() const;
void push_front(const T& INPUT);
void push_back(const T& INPUT);
void pop_front();
void pop_back();
void clear();
unsigned int size() const;
unsigned int max_size() const;
void resize(unsigned int n, const T& INPUT);
void remove(const T& INPUT);
void unique();
void reverse();
@ -153,7 +155,7 @@ namespace std{
if (j<0) j += size;
if (i<0) i = 0;
if (j>size) j = size;
for (int k=0;k<i;k++)
{
first++;
@ -174,7 +176,7 @@ namespace std{
if (j<0) j += size;
if (i<0) i = 0;
if (j>size) j = size;
for (int k=0;k<i;k++)
{
first++;
@ -200,7 +202,6 @@ namespace std{
}
else self->insert(self->end(),v.begin(),v.end());
}
}
unsigned int __len__()
{
@ -218,8 +219,7 @@ namespace std{
{
self->pop_back();
}
};
}
};
}

View file

@ -214,9 +214,14 @@
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &other);
map(const map& other);
size_type size() const;
bool empty() const;
%rename(Clear) clear;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T t, U u);
pair(const pair& p);
pair(T first, U second);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -201,8 +201,13 @@
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef CTYPE value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef CONST_REFERENCE const_reference;
%rename(Clear) clear;
void clear();
%rename(Add) push_back;
@ -212,8 +217,10 @@
void reserve(size_type n);
%newobject GetRange(int index, int count);
%newobject Repeat(CTYPE const& value, int count);
vector();
vector(const vector &other);
%extend {
vector(int capacity) throw (std::out_of_range) {
std::vector< CTYPE >* pv = 0;

View file

@ -1,7 +1,5 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>

View file

@ -23,8 +23,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T t, U u);
pair(const pair& p);
pair(T first, U second);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -104,15 +104,22 @@ public void capacity(size_t value) {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef CTYPE value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef CONST_REFERENCE const_reference;
void clear();
void push_back(CTYPE const& x);
size_type size() const;
size_type capacity() const;
void reserve(size_type n) throw (std::length_error);
vector();
vector(const vector &other);
%extend {
vector(size_type capacity) throw (std::length_error) {
std::vector< CTYPE >* pv = 0;
@ -442,8 +449,13 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef CTYPE value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef CONST_REFERENCE const_reference;
bool empty() const;
void clear();
void push_back(CTYPE const& x);
@ -451,8 +463,10 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
size_type size() const;
size_type capacity() const;
void reserve(size_type n) throw (std::length_error);
vector();
vector(const vector &other);
%extend {
vector(size_type capacity) throw (std::length_error) {
std::vector< CTYPE >* pv = 0;

View file

@ -1,7 +1,5 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>

View file

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
* std_vector.i
* std_list.i
* ----------------------------------------------------------------------------- */
%{
@ -9,7 +9,7 @@
namespace std {
template<class T, class Alloc = allocator<T> >
template<class T>
class list {
public:
typedef size_t size_type;
@ -19,9 +19,10 @@ namespace std {
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef Alloc allocator_type;
list();
list(const list& other);
size_type size() const;
bool empty() const;
%rename(isEmpty) empty;

View file

@ -27,8 +27,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -12,10 +12,17 @@ namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
@ -46,10 +53,17 @@ namespace std {
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef bool value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef bool const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);

View file

@ -7,3 +7,4 @@
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

View file

@ -218,8 +218,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C> &);
map(const map& other);
unsigned int size() const;
bool empty() const;
@ -434,8 +440,18 @@ namespace std {
%rename("delete!") __delitem__;
%rename("has-key?") has_key;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;
@ -640,8 +656,18 @@ namespace std {
%rename("delete!") __delitem__;
%rename("has-key?") has_key;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;
@ -848,8 +874,18 @@ namespace std {
%rename("delete!") __delitem__;
%rename("has-key?") has_key;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C> &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -113,11 +113,15 @@ namespace std {
$1 = 0;
}
}
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;
@ -217,9 +221,9 @@ namespace std {
}
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;
@ -317,9 +321,9 @@ namespace std {
}
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;
@ -408,9 +412,9 @@ namespace std {
}
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -187,9 +187,18 @@ namespace std {
}
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T>&);
vector(const vector& other);
%rename(length) size;
unsigned int size() const;
%rename("empty?") empty;
@ -351,9 +360,18 @@ namespace std {
}
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T>&);
vector(const vector& other);
%rename(length) size;
unsigned int size() const;
%rename("empty?") empty;

View file

@ -1,7 +1,5 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>

View file

@ -11,12 +11,14 @@ namespace std {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T &reference;
typedef const T &const_reference;
typedef T *pointer;
typedef const T *const_pointer;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
array();
array(const array& other);
size_type size() const;
%rename(isEmpty) empty;
bool empty() const;

View file

@ -130,8 +130,12 @@ namespace std {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T &reference;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
/*
* We'd actually be better off having the nested class *not* be static in the wrapper
@ -173,7 +177,8 @@ namespace std {
};
list();
list(const list &other);
list(const list& other);
%rename(isEmpty) empty;
bool empty() const;
void clear();

View file

@ -2,6 +2,8 @@
* std_map.i
*
* SWIG typemaps for std::map
* The Java proxy class extends java.util.AbstractMap. The std::map
* container looks and feels much like a java.util.HashMap from Java.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
@ -12,48 +14,199 @@
%{
#include <map>
#include <algorithm>
#include <stdexcept>
%}
%fragment("SWIG_MapSize", "header", fragment="SWIG_JavaIntFromSize_t") {
SWIGINTERN jint SWIG_MapSize(size_t size) {
jint sz = SWIG_JavaIntFromSize_t(size);
if (sz == -1) {
throw std::out_of_range("map size is too large to fit into a Java int");
}
return sz;
}
}
%javamethodmodifiers std::map::sizeImpl "private";
%javamethodmodifiers std::map::containsImpl "private";
%javamethodmodifiers std::map::putUnchecked "private";
%javamethodmodifiers std::map::removeUnchecked "private";
%javamethodmodifiers std::map::find "private";
%javamethodmodifiers std::map::begin "private";
%javamethodmodifiers std::map::end "private";
%rename(Iterator) std::map::iterator;
%nodefaultctor std::map::iterator;
%javamethodmodifiers std::map::iterator::getNextUnchecked "private";
%javamethodmodifiers std::map::iterator::isNot "private";
%javamethodmodifiers std::map::iterator::getKey "private";
%javamethodmodifiers std::map::iterator::getValue "private";
%javamethodmodifiers std::map::iterator::setValue "private";
namespace std {
template<class K, class T, class C = std::less<K> > class map {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map< K, T, C > &);
template<class K, class T, class C = std::less< K> > class map {
unsigned int size() const;
bool empty() const;
void clear();
%typemap(javabase) std::map< K, T, C >
"java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>"
%proxycode %{
public int size() {
return sizeImpl();
}
public boolean containsKey(Object key) {
if (!(key instanceof $typemap(jboxtype, K))) {
return false;
}
return containsImpl(($typemap(jboxtype, K))key);
}
public $typemap(jboxtype, T) get(Object key) {
if (!(key instanceof $typemap(jboxtype, K))) {
return null;
}
Iterator itr = find(($typemap(jboxtype, K)) key);
if (itr.isNot(end())) {
return itr.getValue();
}
return null;
}
public $typemap(jboxtype, T) put($typemap(jboxtype, K) key, $typemap(jboxtype, T) value) {
Iterator itr = find(($typemap(jboxtype, K)) key);
if (itr.isNot(end())) {
$typemap(jboxtype, T) oldValue = itr.getValue();
itr.setValue(value);
return oldValue;
} else {
putUnchecked(key, value);
return null;
}
}
public $typemap(jboxtype, T) remove(Object key) {
if (!(key instanceof $typemap(jboxtype, K))) {
return null;
}
Iterator itr = find(($typemap(jboxtype, K)) key);
if (itr.isNot(end())) {
$typemap(jboxtype, T) oldValue = itr.getValue();
removeUnchecked(itr);
return oldValue;
} else {
return null;
}
}
public java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> entrySet() {
java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> setToReturn =
new java.util.HashSet<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>>();
Iterator itr = begin();
final Iterator end = end();
while (itr.isNot(end)) {
setToReturn.add(new Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>() {
private Iterator iterator;
private Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)> init(Iterator iterator) {
this.iterator = iterator;
return this;
}
public $typemap(jboxtype, K) getKey() {
return iterator.getKey();
}
public $typemap(jboxtype, T) getValue() {
return iterator.getValue();
}
public $typemap(jboxtype, T) setValue($typemap(jboxtype, T) newValue) {
$typemap(jboxtype, T) oldValue = iterator.getValue();
iterator.setValue(newValue);
return oldValue;
}
}.init(itr));
itr = itr.getNextUnchecked();
}
return setToReturn;
}
%}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map& other);
struct iterator {
%typemap(javaclassmodifiers) iterator "protected class"
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
std::map< K, T, C >::iterator getNextUnchecked() {
std::map< K, T, C >::iterator copy = (*$self);
return ++copy;
}
void set(const K& key, const T& x) {
(*self)[key] = x;
bool isNot(iterator other) const {
return (*$self != other);
}
void del(const K& key) throw (std::out_of_range) {
std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
K getKey() const {
return (*$self)->first;
}
bool has_key(const K& key) {
std::map< K, T, C >::iterator i = self->find(key);
return i != self->end();
T getValue() const {
return (*$self)->second;
}
void setValue(const T& newValue) {
(*$self)->second = newValue;
}
}
};
};
%rename(isEmpty) empty;
bool empty() const;
void clear();
iterator find(const K& key);
iterator begin();
iterator end();
%extend {
%fragment("SWIG_MapSize");
jint sizeImpl() const throw (std::out_of_range) {
return SWIG_MapSize(self->size());
}
bool containsImpl(const K& key) {
return (self->count(key) > 0);
}
void putUnchecked(const K& key, const T& value) {
(*self)[key] = value;
}
void removeUnchecked(const std::map< K, T, C >::iterator itr) {
self->erase(itr);
}
}
};
// Legacy macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)

View file

@ -18,12 +18,15 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

199
Lib/java/std_set.i Normal file
View file

@ -0,0 +1,199 @@
/* -----------------------------------------------------------------------------
* std_set.i
*
* SWIG typemaps for std::set
* The Java proxy class extends java.util.AbstractSet. The std::set
* container looks and feels much like a java.util.HashSet from Java.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::set
// ------------------------------------------------------------------------
%{
#include <set>
#include <stdexcept>
%}
%fragment("SWIG_SetSize", "header", fragment="SWIG_JavaIntFromSize_t") {
SWIGINTERN jint SWIG_SetSize(size_t size) {
jint sz = SWIG_JavaIntFromSize_t(size);
if (sz == -1) {
throw std::out_of_range("set size is too large to fit into a Java int");
}
return sz;
}
}
%javamethodmodifiers std::set::sizeImpl "private";
%javamethodmodifiers std::set::containsImpl "private";
%javamethodmodifiers std::set::removeImpl "private";
%javamethodmodifiers std::set::hasNextImpl "private";
%javamethodmodifiers std::set::begin "private";
%javamethodmodifiers std::set::end "private";
%rename(Iterator) std::set::iterator;
%nodefaultctor std::set::iterator;
%javamethodmodifiers std::set::iterator::incrementUnchecked "private";
%javamethodmodifiers std::set::iterator::derefUnchecked "private";
%javamethodmodifiers std::set::iterator::isNot "private";
namespace std {
template <class T>
class set {
%typemap(javabase) std::set<T> "java.util.AbstractSet<$typemap(jboxtype, T)>"
%proxycode %{
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
this();
addAll(collection);
}
public int size() {
return sizeImpl();
}
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
boolean didAddElement = false;
for (Object object : collection) {
didAddElement |= add(($typemap(jboxtype, T))object);
}
return didAddElement;
}
public java.util.Iterator<$typemap(jboxtype, T)> iterator() {
return new java.util.Iterator<$typemap(jboxtype, T)>() {
private Iterator curr;
private Iterator end;
private java.util.Iterator<$typemap(jboxtype, T)> init() {
curr = $javaclassname.this.begin();
end = $javaclassname.this.end();
return this;
}
public $typemap(jboxtype, T) next() {
if (!hasNext()) {
throw new java.util.NoSuchElementException();
}
// Save the current position, increment it,
// then return the value at the position before the increment.
final $typemap(jboxtype, T) currValue = curr.derefUnchecked();
curr.incrementUnchecked();
return currValue;
}
public boolean hasNext() {
return curr.isNot(end);
}
}.init();
}
public boolean containsAll(java.util.Collection<?> collection) {
for (Object object : collection) {
if (!contains(object)) {
return false;
}
}
return true;
}
public boolean contains(Object object) {
if (!(object instanceof $typemap(jboxtype, T))) {
return false;
}
return containsImpl(($typemap(jboxtype, T))object);
}
public boolean removeAll(java.util.Collection<?> collection) {
boolean didRemoveElement = false;
for (Object object : collection) {
didRemoveElement |= remove(object);
}
return didRemoveElement;
}
public boolean remove(Object object) {
if (!(object instanceof $typemap(jboxtype, T))) {
return false;
}
return removeImpl(($typemap(jboxtype, T))object);
}
%}
public:
struct iterator {
%typemap(javaclassmodifiers) iterator "protected class"
%extend {
void incrementUnchecked() {
++(*$self);
}
T derefUnchecked() const {
return **$self;
}
bool isNot(iterator other) const {
return (*$self != other);
}
}
};
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T key_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
set();
set(const set& other);
%rename(isEmpty) empty;
bool empty() const;
void clear();
iterator begin();
iterator end();
%extend {
%fragment("SWIG_SetSize");
// Returns whether item was inserted.
bool add(const T& key) {
return self->insert(key).second;
}
// Returns whether set contains key.
bool containsImpl(const T& key) {
return (self->count(key) > 0);
}
// Returns whether the item was erased.
bool removeImpl(const T& key) {
return (self->erase(key) > 0);
}
jint sizeImpl() const throw (std::out_of_range) {
return SWIG_SetSize(self->size());
}
bool hasNextImpl(const iterator& itr) const {
return (itr != $self->end());
}
}
};
}

View file

@ -0,0 +1,211 @@
/* -----------------------------------------------------------------------------
* std_unordered_map.i
*
* SWIG typemaps for std::unordered_map
* The Java proxy class extends java.util.AbstractMap. The std::unordered_map
* container looks and feels much like a java.util.HashMap from Java.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::unordered_map
// ------------------------------------------------------------------------
%{
#include <unordered_map>
#include <stdexcept>
%}
%fragment("SWIG_MapSize", "header", fragment="SWIG_JavaIntFromSize_t") {
SWIGINTERN jint SWIG_MapSize(size_t size) {
jint sz = SWIG_JavaIntFromSize_t(size);
if (sz == -1) {
throw std::out_of_range("map size is too large to fit into a Java int");
}
return sz;
}
}
%javamethodmodifiers std::unordered_map::sizeImpl "private";
%javamethodmodifiers std::unordered_map::containsImpl "private";
%javamethodmodifiers std::unordered_map::putUnchecked "private";
%javamethodmodifiers std::unordered_map::removeUnchecked "private";
%javamethodmodifiers std::unordered_map::find "private";
%javamethodmodifiers std::unordered_map::begin "private";
%javamethodmodifiers std::unordered_map::end "private";
%rename(Iterator) std::unordered_map::iterator;
%nodefaultctor std::unordered_map::iterator;
%javamethodmodifiers std::unordered_map::iterator::getNextUnchecked "private";
%javamethodmodifiers std::unordered_map::iterator::isNot "private";
%javamethodmodifiers std::unordered_map::iterator::getKey "private";
%javamethodmodifiers std::unordered_map::iterator::getValue "private";
%javamethodmodifiers std::unordered_map::iterator::setValue "private";
namespace std {
template<class K, class T> class unordered_map {
%typemap(javabase) std::unordered_map<K, T>
"java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>"
%proxycode %{
public int size() {
return sizeImpl();
}
public boolean containsKey(Object key) {
if (!(key instanceof $typemap(jboxtype, K))) {
return false;
}
return containsImpl(($typemap(jboxtype, K))key);
}
public $typemap(jboxtype, T) get(Object key) {
if (!(key instanceof $typemap(jboxtype, K))) {
return null;
}
Iterator itr = find(($typemap(jboxtype, K)) key);
if (itr.isNot(end())) {
return itr.getValue();
}
return null;
}
public $typemap(jboxtype, T) put($typemap(jboxtype, K) key, $typemap(jboxtype, T) value) {
Iterator itr = find(($typemap(jboxtype, K)) key);
if (itr.isNot(end())) {
$typemap(jboxtype, T) oldValue = itr.getValue();
itr.setValue(value);
return oldValue;
} else {
putUnchecked(key, value);
return null;
}
}
public $typemap(jboxtype, T) remove(Object key) {
if (!(key instanceof $typemap(jboxtype, K))) {
return null;
}
Iterator itr = find(($typemap(jboxtype, K)) key);
if (itr.isNot(end())) {
$typemap(jboxtype, T) oldValue = itr.getValue();
removeUnchecked(itr);
return oldValue;
} else {
return null;
}
}
public java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> entrySet() {
java.util.Set<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>> setToReturn =
new java.util.HashSet<Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>>();
Iterator itr = begin();
final Iterator end = end();
while (itr.isNot(end)) {
setToReturn.add(new Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>() {
private Iterator iterator;
private Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)> init(Iterator iterator) {
this.iterator = iterator;
return this;
}
public $typemap(jboxtype, K) getKey() {
return iterator.getKey();
}
public $typemap(jboxtype, T) getValue() {
return iterator.getValue();
}
public $typemap(jboxtype, T) setValue($typemap(jboxtype, T) newValue) {
$typemap(jboxtype, T) oldValue = iterator.getValue();
iterator.setValue(newValue);
return oldValue;
}
}.init(itr));
itr = itr.getNextUnchecked();
}
return setToReturn;
}
%}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
unordered_map();
unordered_map(const unordered_map& other);
struct iterator {
%typemap(javaclassmodifiers) iterator "protected class"
%extend {
std::unordered_map< K, T >::iterator getNextUnchecked() {
std::unordered_map< K, T >::iterator copy = (*$self);
return ++copy;
}
bool isNot(iterator other) const {
return (*$self != other);
}
K getKey() const {
return (*$self)->first;
}
T getValue() const {
return (*$self)->second;
}
void setValue(const T& newValue) {
(*$self)->second = newValue;
}
}
};
%rename(isEmpty) empty;
bool empty() const;
void clear();
iterator find(const K& key);
iterator begin();
iterator end();
%extend {
%fragment("SWIG_MapSize");
jint sizeImpl() const throw (std::out_of_range) {
return SWIG_MapSize(self->size());
}
bool containsImpl(const K& key) {
return (self->count(key) > 0);
}
void putUnchecked(const K& key, const T& value) {
(*self)[key] = value;
}
void removeUnchecked(const std::unordered_map< K, T >::iterator itr) {
self->erase(itr);
}
}
};
}

View file

@ -0,0 +1,199 @@
/* -----------------------------------------------------------------------------
* std_unordered_set.i
*
* SWIG typemaps for std::unordered_set
* The Java proxy class extends java.util.AbstractSet. The std::unordered_set
* container looks and feels much like a java.util.HashSet from Java.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::unordered_set
// ------------------------------------------------------------------------
%{
#include <unordered_set>
#include <stdexcept>
%}
%fragment("SWIG_UnorderedSetSize", "header", fragment="SWIG_JavaIntFromSize_t") {
SWIGINTERN jint SWIG_UnorderedSetSize(size_t size) {
jint sz = SWIG_JavaIntFromSize_t(size);
if (sz == -1) {
throw std::out_of_range("unordered_set size is too large to fit into a Java int");
}
return sz;
}
}
%javamethodmodifiers std::unordered_set::sizeImpl "private";
%javamethodmodifiers std::unordered_set::containsImpl "private";
%javamethodmodifiers std::unordered_set::removeImpl "private";
%javamethodmodifiers std::unordered_set::hasNextImpl "private";
%javamethodmodifiers std::unordered_set::begin "private";
%javamethodmodifiers std::unordered_set::end "private";
%rename(Iterator) std::unordered_set::iterator;
%nodefaultctor std::unordered_set::iterator;
%javamethodmodifiers std::unordered_set::iterator::incrementUnchecked "private";
%javamethodmodifiers std::unordered_set::iterator::derefUnchecked "private";
%javamethodmodifiers std::unordered_set::iterator::isNot "private";
namespace std {
template <class T>
class unordered_set {
%typemap(javabase) std::unordered_set<T> "java.util.AbstractSet<$typemap(jboxtype, T)>"
%proxycode %{
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
this();
addAll(collection);
}
public int size() {
return sizeImpl();
}
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
boolean didAddElement = false;
for (Object object : collection) {
didAddElement |= add(($typemap(jboxtype, T))object);
}
return didAddElement;
}
public java.util.Iterator<$typemap(jboxtype, T)> iterator() {
return new java.util.Iterator<$typemap(jboxtype, T)>() {
private Iterator curr;
private Iterator end;
private java.util.Iterator<$typemap(jboxtype, T)> init() {
curr = $javaclassname.this.begin();
end = $javaclassname.this.end();
return this;
}
public $typemap(jboxtype, T) next() {
if (!hasNext()) {
throw new java.util.NoSuchElementException();
}
// Save the current position, increment it,
// then return the value at the position before the increment.
final $typemap(jboxtype, T) currValue = curr.derefUnchecked();
curr.incrementUnchecked();
return currValue;
}
public boolean hasNext() {
return curr.isNot(end);
}
}.init();
}
public boolean containsAll(java.util.Collection<?> collection) {
for (Object object : collection) {
if (!contains(object)) {
return false;
}
}
return true;
}
public boolean contains(Object object) {
if (!(object instanceof $typemap(jboxtype, T))) {
return false;
}
return containsImpl(($typemap(jboxtype, T))object);
}
public boolean removeAll(java.util.Collection<?> collection) {
boolean didRemoveElement = false;
for (Object object : collection) {
didRemoveElement |= remove(object);
}
return didRemoveElement;
}
public boolean remove(Object object) {
if (!(object instanceof $typemap(jboxtype, T))) {
return false;
}
return removeImpl(($typemap(jboxtype, T))object);
}
%}
public:
struct iterator {
%typemap(javaclassmodifiers) iterator "protected class"
%extend {
void incrementUnchecked() {
++(*$self);
}
T derefUnchecked() const {
return **$self;
}
bool isNot(iterator other) const {
return (*$self != other);
}
}
};
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T key_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
unordered_set();
unordered_set(const unordered_set& other);
%rename(isEmpty) empty;
bool empty() const;
void clear();
iterator begin();
iterator end();
%extend {
%fragment("SWIG_UnorderedSetSize");
// Returns whether item was inserted.
bool add(const T& key) {
return self->insert(key).second;
}
// Returns whether set contains key.
bool containsImpl(const T& key) {
return (self->count(key) > 0);
}
// Returns whether the item was erased.
bool removeImpl(const T& key) {
return (self->erase(key) > 0);
}
jint sizeImpl() const throw (std::out_of_range) {
return SWIG_UnorderedSetSize(self->size());
}
bool hasNextImpl(const iterator& itr) const {
return (itr != $self->end());
}
}
};
}

View file

@ -23,7 +23,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
}
}
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE)
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CONST_REFERENCE)
%typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>"
%typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess"
%proxycode %{
@ -79,13 +79,14 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef CTYPE value_type;
typedef CTYPE &reference;
typedef CREF_TYPE const_reference;
typedef CTYPE *pointer;
typedef CTYPE const *const_pointer;
typedef CTYPE &reference;
typedef CONST_REFERENCE const_reference;
vector();
vector(const vector &other);
size_type capacity() const;
void reserve(size_type n) throw (std::length_error);
%rename(isEmpty) empty;
@ -133,7 +134,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) {
}
}
CREF_TYPE doGet(jint index) throw (std::out_of_range) {
CONST_REFERENCE doGet(jint index) throw (std::out_of_range) {
jint size = static_cast<jint>(self->size());
if (index >= 0 && index < size)
return (*self)[index];

View file

@ -27,8 +27,15 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -14,10 +14,17 @@ namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
@ -48,10 +55,17 @@ namespace std {
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef bool value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef bool const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);

View file

@ -27,8 +27,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -17,12 +17,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -14,10 +14,17 @@ namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
@ -48,10 +55,17 @@ namespace std {
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef bool value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef bool const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);

View file

@ -27,8 +27,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C> &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -7,21 +7,6 @@
%{
#include <utility>
%}
/*
A really cut down version of the pair class.
this is not useful on its own - it needs a %template definition with it
eg.
namespace std {
%template(IntPair) pair<int, int>;
%template(make_IntPair) make_pair<int, int>;
}
*/
namespace std {
template <class T, class U > struct pair {
@ -30,13 +15,12 @@ namespace std {
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
T first;
U second;
};
template <class T, class U >
pair<T,U> make_pair(const T&,const U&);
pair<T,U> make_pair(const T& first, const U& second);
}

View file

@ -109,7 +109,6 @@ as this is overloaded by the const char* version
public:
string();
string(const char*);
//string(const string&);
unsigned int size() const;
unsigned int length() const;
bool empty() const;
@ -119,7 +118,6 @@ as this is overloaded by the const char* version
// assign does not return a copy of this object
// (no point in a scripting language)
void assign(const char*);
//void assign(const string&);
// no support for all the other features
// it's probably better to do it in lua
};

View file

@ -25,10 +25,19 @@ namespace std {
template<class T>
class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector();
vector(unsigned int);
vector(const vector&);
vector(const vector& other);
vector(unsigned int,T);
unsigned int size() const;
unsigned int max_size() const;
bool empty() const;

View file

@ -221,8 +221,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;
@ -441,8 +447,18 @@ namespace std {
%rename("delete!") __delitem__;
%rename("has-key?") has_key;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;
@ -653,8 +669,18 @@ namespace std {
%rename("delete!") __delitem__;
%rename("has-key?") has_key;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;
@ -865,8 +891,18 @@ namespace std {
%rename("delete!") __delitem__;
%rename("has-key?") has_key;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -115,11 +115,15 @@ namespace std {
$1 = 0;
}
}
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;
@ -219,9 +223,9 @@ namespace std {
}
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;
@ -320,9 +324,9 @@ namespace std {
}
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;
@ -415,9 +419,9 @@ namespace std {
}
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -189,9 +189,18 @@ namespace std {
}
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T>&);
vector(const vector& other);
%rename(length) size;
unsigned int size() const;
%rename("empty?") empty;
@ -365,9 +374,18 @@ namespace std {
}
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T>&);
vector(const vector& other);
%rename(length) size;
unsigned int size() const;
%rename("empty?") empty;

View file

@ -1,8 +1,7 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>

View file

@ -13,21 +13,24 @@
%}
namespace std{
namespace std {
template<class T> class list
{
public:
typedef T &reference;
typedef const T& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef T &iterator;
typedef const T& const_iterator;
list();
list(unsigned int size, const T& value = T());
list(const list<T> &);
list(const list& other);
~list();
void assign(unsigned int n, const T& value);
void swap(list<T> &x);
@ -35,28 +38,25 @@ namespace std{
const_reference back();
const_iterator begin();
const_iterator end();
void resize(unsigned int n, T c = T());
bool empty() const;
void push_front(const T& x);
void push_back(const T& x);
void pop_front();
void pop_back();
void clear();
unsigned int size() const;
unsigned int max_size() const;
void resize(unsigned int n, const T& value);
void remove(const T& value);
void unique();
void reverse();
void sort();
%extend
{
const_reference __getitem__(int i) throw (std::out_of_range)
@ -206,9 +206,7 @@ namespace std{
{
self->pop_back();
}
};
}
};
}

View file

@ -26,8 +26,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -41,9 +41,18 @@
namespace std {
template <class T> class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T>&);
vector(const vector& other);
unsigned int size() const;
bool empty() const;
void clear();

View file

@ -1,7 +1,5 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>

View file

@ -12,7 +12,7 @@
template <class T>
struct traits_from<std::deque<T> > {
static octave_value from(const std::deque<T> & vec) {
static octave_value from(const std::deque<T>& vec) {
return traits_from_stdseq<std::deque<T> >::from(vec);
}
};

View file

@ -12,7 +12,7 @@
template <class T>
struct traits_from<std::list<T> > {
static octave_value *from(const std::list<T> & vec) {
static octave_value *from(const std::list<T>& vec) {
return traits_from_stdseq<std::list<T> >::from(vec);
}
};

View file

@ -1,6 +1,10 @@
/* initial STL definition. extended as needed in each language */
/* -----------------------------------------------------------------------------
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

View file

@ -189,11 +189,15 @@ namespace std {
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
list();
list(const list<T> &);
list(const list& other);
unsigned int size() const;
bool empty() const;
@ -346,7 +350,7 @@ namespace std {
typedef const value_type& const_reference;
list();
list(const list<T> &);
list(const list& other);
unsigned int size() const;
bool empty() const;

View file

@ -27,8 +27,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T t, U u);
pair(const pair& p);
pair(T first, U second);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -181,11 +181,16 @@ namespace std {
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, const T& value);
vector(const vector<T> &);
vector(const vector& other);
unsigned int size() const;
bool empty() const;
@ -353,11 +358,16 @@ namespace std {
}
public:
typedef size_t size_type;
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, T *value);
vector(const vector<T *> &);
vector(const vector& other);
unsigned int size() const;
bool empty() const;
@ -524,11 +534,16 @@ namespace std {
}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector(unsigned int size = 0);
vector(unsigned int size, T value);
vector(const vector<T> &);
vector(const vector& other);
unsigned int size() const;
bool empty() const;

View file

@ -1,8 +1,7 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>

View file

@ -27,8 +27,14 @@ namespace std {
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
void clear();

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -14,10 +14,17 @@ namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
@ -56,10 +63,17 @@ namespace std {
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef bool value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef bool const_reference;
vector();
vector(size_type n);
vector(const vector& other);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);

View file

@ -1,7 +1,5 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>

View file

@ -14,7 +14,7 @@
template <class T>
struct traits_from<std::deque<T> > {
static PyObject *from(const std::deque<T> & vec) {
static PyObject *from(const std::deque<T>& vec) {
return traits_from_stdseq<std::deque<T> >::from(vec);
}
};

View file

@ -14,7 +14,7 @@
template <class T>
struct traits_from<std::list<T> > {
static PyObject *from(const std::list<T> & vec) {
static PyObject *from(const std::list<T>& vec) {
return traits_from_stdseq<std::list<T> >::from(vec);
}
};

View file

@ -1,4 +1,7 @@
/* initial STL definition. extended as needed in each language */
/* -----------------------------------------------------------------------------
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>

View file

@ -1,10 +1,9 @@
/* initial STL definition. extended as needed in each language */
%include std_common.i
%include std_vector.i
%include std_pair.i
%include std_string.i
/* -----------------------------------------------------------------------------
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>
%include <std_pair.i>

View file

@ -943,7 +943,7 @@ namespace swig
}
}
catch( const std::invalid_argument & )
catch(const std::invalid_argument &)
{
rb_raise( rb_eArgError, "%s",
Ruby_Format_TypeError( "",
@ -970,7 +970,7 @@ namespace swig
Sequence::value_type val = swig::as<Sequence::value_type>( elem );
$self->insert( start, val );
}
catch( const std::invalid_argument & )
catch(const std::invalid_argument &)
{
rb_raise( rb_eArgError, "%s",
Ruby_Format_TypeError( "",

View file

@ -69,7 +69,7 @@
*i = swig::as< Type >( r );
}
}
catch ( const std::invalid_argument& )
catch (const std::invalid_argument&)
{
rb_raise(rb_eTypeError,
"Yield block did not return a valid element for " "Container");

View file

@ -14,7 +14,7 @@
template <class T>
struct traits_from<std::deque<T> > {
static VALUE from(const std::deque<T> & vec) {
static VALUE from(const std::deque<T>& vec) {
return traits_from_stdseq<std::deque<T> >::from(vec);
}
};

View file

@ -14,7 +14,7 @@
template <class T>
struct traits_from<std::list<T> > {
static VALUE from(const std::list<T> & vec) {
static VALUE from(const std::list<T>& vec) {
return traits_from_stdseq<std::list<T> >::from(vec);
}
};

View file

@ -14,7 +14,7 @@
template <class T>
struct traits_from<std::queue<T> > {
static VALUE from(const std::queue<T> & vec) {
static VALUE from(const std::queue<T>& vec) {
return traits_from_stdseq<std::queue<T> >::from(vec);
}
};

View file

@ -14,7 +14,7 @@
template <class T>
struct traits_from<std::stack<T> > {
static VALUE from(const std::stack<T> & vec) {
static VALUE from(const std::stack<T>& vec) {
return traits_from_stdseq<std::stack<T> >::from(vec);
}
};

View file

@ -1,7 +1,5 @@
/* -----------------------------------------------------------------------------
* stl.i
*
* Initial STL definition. extended as needed in each language
* ----------------------------------------------------------------------------- */
%include <std_common.i>

View file

@ -22,8 +22,18 @@ namespace std {
template<class K, class T, class C = std::less<K> > class map {
// add typemaps here
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
typedef std::pair< const K, T > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
map();
map(const map< K, T, C > &);
map(const map& other);
unsigned int size() const;
bool empty() const;

View file

@ -18,12 +18,14 @@
namespace std {
template<class T, class U> struct pair {
typedef T first_type;
typedef U second_type;
pair();
pair(T first, U second);
pair(const pair& p);
pair(const pair& other);
template <class U1, class U2> pair(const pair<U1, U2> &p);
template <class U1, class U2> pair(const pair<U1, U2> &other);
T first;
U second;

View file

@ -1,6 +1,10 @@
/* initial STL definition. extended as needed in each language */
/* -----------------------------------------------------------------------------
* stl.i
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>
%include <std_map.i>
%include <std_pair.i>

View file

@ -31,9 +31,9 @@ namespace std
allocator() throw();
allocator(const allocator&) throw();
allocator(const allocator& other) throw();
template<typename _Tp1>
allocator(const allocator<_Tp1>&) throw();
allocator(const allocator<_Tp1>& other) throw();
~allocator() throw();

View file

@ -53,8 +53,8 @@ namespace std {
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef value_type& reference;
typedef const value_type& const_reference;
%traits_swigtype(_Tp);
%traits_enum(_Tp);

View file

@ -28,8 +28,8 @@ namespace std {
carray() { }
carray(const carray& c) {
std::copy(c.v, c.v + size(), v);
carray(const carray& other) {
std::copy(other.v, other.v + size(), v);
}
template <class _Iterator>

View file

@ -11,7 +11,7 @@
%define %std_container_methods_non_resizable(container...)
container();
container(const container&);
container(const container& other);
bool empty() const;
size_type size() const;

View file

@ -153,10 +153,10 @@ namespace std {
//50. Copy constructor and assignment operator of ios_base
private:
ios_base(const ios_base&);
ios_base(const ios_base& other);
ios_base&
operator=(const ios_base&);
operator=(const ios_base& other);
};
template<typename _CharT, typename _Traits = char_traits<_CharT> >
@ -242,10 +242,10 @@ namespace std {
// 27.4.5.1 basic_ios constructors
basic_ios();
private:
basic_ios(const basic_ios&);
basic_ios(const basic_ios& other);
basic_ios&
operator=(const basic_ios&);
operator=(const basic_ios& other);
};
}

View file

@ -306,15 +306,15 @@ namespace std
template<typename _CharT, typename _Traits = char_traits<_CharT> >
std::basic_ostream<_CharT, _Traits>&
endl(std::basic_ostream<_CharT, _Traits>&);
endl(std::basic_ostream<_CharT, _Traits>& value);
template<typename _CharT, typename _Traits = char_traits<_CharT> >
std::basic_ostream<_CharT, _Traits>&
ends(std::basic_ostream<_CharT, _Traits>&);
ends(std::basic_ostream<_CharT, _Traits>& value);
template<typename _CharT, typename _Traits = char_traits<_CharT> >
std::basic_ostream<_CharT, _Traits>&
flush(std::basic_ostream<_CharT, _Traits>&);
flush(std::basic_ostream<_CharT, _Traits>& value);
}
namespace std {

View file

@ -106,8 +106,8 @@ namespace std {
typedef _Tp* value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type reference;
typedef value_type const_reference;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef _Alloc allocator_type;
%traits_swigtype(_Tp);

View file

@ -74,7 +74,6 @@ namespace std {
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair< const _Key, _Tp > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
@ -113,7 +112,7 @@ namespace std {
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map< _Key, _Tp, _Compare, _Alloc >);
map( const _Compare& );
map(const _Compare& other);
#ifdef %swig_map_methods
// Add swig/language extra methods

View file

@ -50,7 +50,6 @@ namespace std {
typedef _Key key_type;
typedef _Tp mapped_type;
typedef std::pair< const _Key, _Tp > value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
@ -89,7 +88,7 @@ namespace std {
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap< _Key, _Tp, _Compare, _Alloc >);
multimap( const _Compare& );
multimap(const _Compare& other);
#ifdef %swig_multimap_methods
// Add swig/language extra methods

View file

@ -71,7 +71,7 @@ namespace std {
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset< _Key, _Compare, _Alloc >);
multiset( const _Compare& );
multiset(const _Compare& other);
#ifdef %swig_multiset_methods
// Add swig/language extra methods

Some files were not shown because too many files have changed in this diff Show more