1 module wrap_all;
2 
3 import templates2;
4 import impl: OtherString;
5 
6 // should be registered in Python as identity_int
7 alias identityInt = identity!int;
8 
9 int product(int i, int j) {
10     return i * j;
11 }
12 
13 struct String {
14     string s;
15     this(string s) { this.s = s; }
16 }
17 
18 
19 string otherStringAsParam(OtherString s) {
20     return s.s ~ "quux";
21 }
22 
23 
24 enum MyEnum {
25     foo,
26     bar,
27     baz,
28 }
29 
30 
31 // FIXME
32 // See https://github.com/symmetryinvestments/autowrap/issues/177
33 version(Have_autowrap_csharp) {}
34 else {
35 
36     // mimics std.range.chain
37     auto mychain(Ranges...)(Ranges ranges) {
38 
39         static struct Oops {
40             import std.meta: staticMap;
41             import std.traits: Unqual;
42             alias R = staticMap!(Unqual, Ranges);
43         }
44 
45         return Oops();
46     }
47 
48 
49     auto chainy() {
50         import std.range: iota;
51         return mychain(5.iota, 7.iota);
52 
53     }
54 }
55 
56 
57 struct HasOnlyOpIndex {
58     bool opIndex(size_t i) @safe @nogc pure nothrow const {
59         return i == 42;
60     }
61 }
62 
63 
64 extern(C) int mysend(int, const(void)* ptr, ulong length, int index) {
65     auto bytes = cast(ubyte*) ptr;
66     if(index > length) throw new Exception("index cannot be more than length");
67     return cast(int) bytes[index];
68 
69 }
70 
71 static if(!is(typeof(GLOBAL_INT_ENUM))) {
72     enum GLOBAL_INT_ENUM = 42;
73 }
74 
75 
76 static if(!is(typeof(GLOBAL_STRING_ENUM))) {
77     enum GLOBAL_STRING_ENUM = "quux";
78 }
79 
80 enum GLOBAL_EMPTY_STRING_ENUM = "";
81 
82 const(char)* intToString(int i) {
83     import std.conv: text;
84     import std..string: toStringz;
85     return i.text.toStringz;
86 }
87 
88 
89 // FIXME
90 version(Have_autowrap_csharp) {}
91 else {
92     class ImmutableFields {
93         this(string name) { this.name = name; }
94         immutable string name;
95     }
96 }