Commit | Line | Data |
---|---|---|
86c1c2e9 | 1 | #include <string> |
e5bc4700 JT |
2 | // serialization of string |
3 | #include <boost/serialization/string.hpp> | |
4 | // serialization of pair | |
5 | #include <boost/serialization/utility.hpp> | |
6 | ||
7 | // std::vector | |
8 | #include <vector> | |
9 | #include <boost/serialization/vector.hpp> | |
10 | ||
63291e4f JT |
11 | #include "foo.hxx" |
12 | ||
86c1c2e9 JT |
13 | #include "codegen_common.hxx" |
14 | ||
472456ca | 15 | LIBT2N_SET_DEFAULTGROUP(default); |
86c1c2e9 | 16 | |
e5bc4700 | 17 | //! test pass by copy |
86c1c2e9 JT |
18 | LIBT2N_EXPORT std::string testfunc(std::string str) |
19 | { | |
71ae912c JT |
20 | std::string ret; |
21 | if (str=="throw") | |
22 | throw libt2n::t2n_runtime_error("throw me around"); | |
23 | if (str=="big") | |
24 | ret.insert(0,100*1024,'x'); | |
25 | else | |
26 | ret=str+", testfunc() was here"; | |
27 | return ret; | |
28 | } | |
29 | ||
e5bc4700 | 30 | //! test pass by const reference |
71ae912c JT |
31 | LIBT2N_EXPORT std::string testfunc_ref(const std::string &str) |
32 | { | |
33 | std::string ret; | |
86c1c2e9 JT |
34 | if (str=="throw") |
35 | throw libt2n::t2n_runtime_error("throw me around"); | |
36 | if (str=="big") | |
37 | ret.insert(0,100*1024,'x'); | |
38 | else | |
39 | ret=str+", testfunc() was here"; | |
40 | return ret; | |
41 | } | |
71ae912c | 42 | |
e5bc4700 | 43 | //! test builtin type |
71ae912c JT |
44 | LIBT2N_EXPORT int t2(int i) |
45 | { | |
46 | return i; | |
47 | } | |
48 | ||
49 | using namespace std; | |
50 | ||
e5bc4700 | 51 | //! test pair, multiple arguments and namespace |
29ba0e97 | 52 | LIBT2N_EXPORT_GROUP(other) bool t3(int i, float f, const string &s, const pair<int, float> &p) |
71ae912c JT |
53 | { |
54 | return (i==p.first) && (f==p.second) && (s=="hello"); | |
55 | } | |
472456ca | 56 | |
e5bc4700 | 57 | //! test function overload |
472456ca JT |
58 | LIBT2N_EXPORT_GROUP(other) int t3(int i) |
59 | { | |
60 | return i; | |
61 | } | |
e5bc4700 JT |
62 | |
63 | //! test std::vector | |
64 | LIBT2N_EXPORT_GROUP(other) bool t3(const std::vector<int> &i) | |
65 | { | |
66 | return (i.size()==1) && (i[0]==10); | |
67 | } | |
63291e4f JT |
68 | |
69 | //! test own type and seperate declaration and definition | |
70 | LIBT2N_EXPORT_GROUP(other) bool t3(const Foo &foo); |