Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | package; |
| 21 | |
| 22 | import org.apache.thrift.*; |
| 23 | import org.apache.thrift.protocol.*; |
| 24 | import org.apache.thrift.transport.*; |
| 25 | import org.apache.thrift.server.*; |
| 26 | import org.apache.thrift.meta_data.*; |
| 27 | import org.apache.thrift.helper.*; |
| 28 | |
| 29 | import haxe.Int32; |
| 30 | import haxe.Int64; |
| 31 | import haxe.io.Bytes; |
| 32 | import haxe.ds.IntMap; |
| 33 | import haxe.ds.StringMap; |
| 34 | import haxe.ds.ObjectMap; |
| 35 | |
| 36 | import thrift.test.*; // generated code |
| 37 | |
| 38 | |
| 39 | class TestServerHandler implements ThriftTest { |
| 40 | |
| 41 | public var server:TServer; |
| 42 | |
| 43 | public function new() { |
| 44 | } |
| 45 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 46 | /** |
| 47 | * Prints "testVoid()" and returns nothing. |
| 48 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 49 | public function testVoid():Void |
| 50 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 51 | trace("testVoid()"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 52 | } |
| 53 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 54 | /** |
| 55 | * Prints 'testString("%s")' with thing as '%s' |
| 56 | * @param string thing - the string to print |
| 57 | * @return string - returns the string 'thing' |
| 58 | * |
| 59 | * @param thing |
| 60 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 61 | public function testString(thing:String):String |
| 62 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 63 | trace("teststring(\"" + thing + "\")"); |
| 64 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 65 | } |
| 66 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 67 | /** |
| 68 | * Prints 'testByte("%d")' with thing as '%d' |
| 69 | * @param byte thing - the byte to print |
| 70 | * @return byte - returns the byte 'thing' |
| 71 | * |
| 72 | * @param thing |
| 73 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 74 | public function testByte(thing:haxe.Int32):haxe.Int32 |
| 75 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 76 | trace("testByte(" + thing + ")"); |
| 77 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 78 | } |
| 79 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 80 | /** |
| 81 | * Prints 'testI32("%d")' with thing as '%d' |
| 82 | * @param i32 thing - the i32 to print |
| 83 | * @return i32 - returns the i32 'thing' |
| 84 | * |
| 85 | * @param thing |
| 86 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 87 | public function testI32(thing:haxe.Int32):haxe.Int32 |
| 88 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 89 | trace("testI32(" + thing + ")"); |
| 90 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 91 | } |
| 92 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 93 | /** |
| 94 | * Prints 'testI64("%d")' with thing as '%d' |
| 95 | * @param i64 thing - the i64 to print |
| 96 | * @return i64 - returns the i64 'thing' |
| 97 | * |
| 98 | * @param thing |
| 99 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 100 | public function testI64(thing:haxe.Int64):haxe.Int64 |
| 101 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 102 | trace("testI64(" + thing + ")"); |
| 103 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 104 | } |
| 105 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 106 | /** |
| 107 | * Prints 'testDouble("%f")' with thing as '%f' |
| 108 | * @param double thing - the double to print |
| 109 | * @return double - returns the double 'thing' |
| 110 | * |
| 111 | * @param thing |
| 112 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 113 | public function testDouble(thing:Float):Float |
| 114 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 115 | trace("testDouble(" + thing + ")"); |
| 116 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 117 | } |
| 118 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 119 | /** |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 120 | * Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data |
| 121 | * @param binary thing - the binary data to print |
| 122 | * @return binary - returns the binary 'thing' |
Jens Geyer | 426ab86 | 2015-03-02 23:37:15 +0100 | [diff] [blame] | 123 | * |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 124 | * @param thing |
| 125 | */ |
| 126 | public function testBinary(thing : haxe.io.Bytes) : haxe.io.Bytes |
| 127 | { |
Jens Geyer | 426ab86 | 2015-03-02 23:37:15 +0100 | [diff] [blame] | 128 | var hex = ""; |
| 129 | for ( i in 0 ... thing.length) { |
| 130 | hex += StringTools.hex( thing.get(i), 2); |
| 131 | } |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 132 | trace('testBinary($hex)'); |
| 133 | return thing; |
| 134 | } |
Jens Geyer | 426ab86 | 2015-03-02 23:37:15 +0100 | [diff] [blame] | 135 | |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 136 | /** |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 137 | * Prints 'testStruct("{%s}")' where thing has been formatted |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 138 | * into a string of comma separated values |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 139 | * @param Xtruct thing - the Xtruct to print |
| 140 | * @return Xtruct - returns the Xtruct 'thing' |
| 141 | * |
| 142 | * @param thing |
| 143 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 144 | public function testStruct(thing:Xtruct):Xtruct |
| 145 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 146 | trace("testStruct({" + |
| 147 | "\"" + thing.string_thing + "\", " + |
| 148 | thing.byte_thing + ", " + |
| 149 | thing.i32_thing + ", " + |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 150 | Int64.toStr(thing.i64_thing) + "})"); |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 151 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 152 | } |
| 153 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 154 | /** |
| 155 | * Prints 'testNest("{%s}")' where thing has been formatted |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 156 | * into a string of the nested struct |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 157 | * @param Xtruct2 thing - the Xtruct2 to print |
| 158 | * @return Xtruct2 - returns the Xtruct2 'thing' |
| 159 | * |
| 160 | * @param thing |
| 161 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 162 | public function testNest(nest:Xtruct2):Xtruct2 |
| 163 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 164 | var thing:Xtruct = nest.struct_thing; |
| 165 | trace("testNest({" + |
| 166 | nest.byte_thing + ", {" + |
| 167 | "\"" + thing.string_thing + "\", " + |
| 168 | thing.byte_thing + ", " + |
| 169 | thing.i32_thing + ", " + |
| 170 | Int64.toStr(thing.i64_thing) + "}, " + |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 171 | nest.i32_thing + "})"); |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 172 | return nest; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 173 | } |
| 174 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 175 | /** |
| 176 | * Prints 'testMap("{%s")' where thing has been formatted |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 177 | * into a string of 'key => value' pairs |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 178 | * separated by commas and new lines |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 179 | * @param map<i32,i32> thing - the map<i32,i32> to print |
| 180 | * @return map<i32,i32> - returns the map<i32,i32> 'thing' |
| 181 | * |
| 182 | * @param thing |
| 183 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 184 | public function testMap(thing:IntMap<haxe.Int32>):IntMap<haxe.Int32> |
| 185 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 186 | trace("testMap({"); |
| 187 | var first:Bool = true; |
| 188 | for (key in thing.keys()) { |
| 189 | if (first) { |
| 190 | first = false; |
| 191 | } else { |
| 192 | trace(", "); |
| 193 | }; |
| 194 | trace(key + " => " + thing.get(key)); |
| 195 | }; |
| 196 | trace("})"); |
| 197 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 198 | } |
| 199 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 200 | /** |
| 201 | * Prints 'testStringMap("{%s}")' where thing has been formatted |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 202 | * into a string of 'key => value' pairs |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 203 | * separated by commas and new lines |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 204 | * @param map<string,string> thing - the map<string,string> to print |
| 205 | * @return map<string,string> - returns the map<string,string> 'thing' |
| 206 | * |
| 207 | * @param thing |
| 208 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 209 | public function testStringMap(thing:StringMap<String>):StringMap<String> |
| 210 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 211 | trace("testStringMap({"); |
| 212 | var first:Bool = true; |
| 213 | for (key in thing.keys()) { |
| 214 | if (first) { |
| 215 | first = false; |
| 216 | } else { |
| 217 | trace(", "); |
| 218 | }; |
| 219 | trace(key + " => " + thing.get(key)); |
| 220 | }; |
| 221 | trace("})"); |
| 222 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 223 | } |
| 224 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 225 | /** |
| 226 | * Prints 'testSet("{%s}")' where thing has been formatted |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 227 | * into a string of values |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 228 | * separated by commas and new lines |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 229 | * @param set<i32> thing - the set<i32> to print |
| 230 | * @return set<i32> - returns the set<i32> 'thing' |
| 231 | * |
| 232 | * @param thing |
| 233 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 234 | public function testSet(thing:IntSet):IntSet |
| 235 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 236 | trace("testSet({"); |
| 237 | var first:Bool = true; |
| 238 | for (elem in thing) { |
| 239 | if (first) { |
| 240 | first = false; |
| 241 | } else { |
| 242 | trace(", "); |
| 243 | }; |
| 244 | trace(elem); |
| 245 | }; |
| 246 | trace("})"); |
| 247 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 248 | } |
| 249 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 250 | /** |
| 251 | * Prints 'testList("{%s}")' where thing has been formatted |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 252 | * into a string of values |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 253 | * separated by commas and new lines |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 254 | * @param list<i32> thing - the list<i32> to print |
| 255 | * @return list<i32> - returns the list<i32> 'thing' |
| 256 | * |
| 257 | * @param thing |
| 258 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 259 | public function testList(thing:List<haxe.Int32>):List<haxe.Int32> |
| 260 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 261 | trace("testList({"); |
| 262 | var first:Bool = true; |
| 263 | for (elem in thing) { |
| 264 | if (first) { |
| 265 | first = false; |
| 266 | } else { |
| 267 | trace(", "); |
| 268 | }; |
| 269 | trace(elem); |
| 270 | }; |
| 271 | trace("})"); |
| 272 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 273 | } |
| 274 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 275 | /** |
| 276 | * Prints 'testEnum("%d")' where thing has been formatted into it's numeric value |
| 277 | * @param Numberz thing - the Numberz to print |
| 278 | * @return Numberz - returns the Numberz 'thing' |
| 279 | * |
| 280 | * @param thing |
| 281 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 282 | public function testEnum(thing:Int):Int |
| 283 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 284 | trace("testEnum(" + thing + ")"); |
| 285 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 286 | } |
| 287 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 288 | /** |
| 289 | * Prints 'testTypedef("%d")' with thing as '%d' |
| 290 | * @param UserId thing - the UserId to print |
| 291 | * @return UserId - returns the UserId 'thing' |
| 292 | * |
| 293 | * @param thing |
| 294 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 295 | public function testTypedef(thing:haxe.Int64):haxe.Int64 |
| 296 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 297 | trace("testTypedef(" + thing + ")"); |
| 298 | return thing; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 299 | } |
| 300 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 301 | /** |
| 302 | * Prints 'testMapMap("%d")' with hello as '%d' |
| 303 | * @param i32 hello - the i32 to print |
| 304 | * @return map<i32,map<i32,i32>> - returns a dictionary with these values: |
| 305 | * {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, |
| 306 | * 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } |
| 307 | * |
| 308 | * @param hello |
| 309 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 310 | public function testMapMap(hello:haxe.Int32):IntMap<IntMap<haxe.Int32>> |
| 311 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 312 | trace("testMapMap(" + hello + ")"); |
| 313 | var mapmap = new IntMap<IntMap<Int>>(); |
| 314 | var pos = new IntMap<Int>(); |
| 315 | var neg = new IntMap<Int>(); |
| 316 | for (i in 1 ... 5) { |
| 317 | pos.set(i, i); |
| 318 | neg.set(-i, -i); |
| 319 | }; |
| 320 | mapmap.set(4, pos); |
| 321 | mapmap.set(-4, neg); |
| 322 | return mapmap; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 325 | /** |
| 326 | * So you think you've got this all worked, out eh? |
| 327 | * |
| 328 | * Creates a the returned map with these values and prints it out: |
| 329 | * { 1 => { 2 => argument, |
| 330 | * 3 => argument, |
| 331 | * }, |
| 332 | * 2 => { 6 => <empty Insanity struct>, }, |
| 333 | * } |
| 334 | * @return map<UserId, map<Numberz,Insanity>> - a map with the above values |
| 335 | * |
| 336 | * @param argument |
| 337 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 338 | public function testInsanity(argument : Insanity) : Int64Map< IntMap< Insanity>> |
| 339 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 340 | trace("testInsanity()"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 341 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 342 | var hello = new Xtruct(); |
| 343 | hello.string_thing = "Hello2"; |
| 344 | hello.byte_thing = 2; |
| 345 | hello.i32_thing = 2; |
| 346 | hello.i64_thing = Int64.make(0, 2); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 347 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 348 | var goodbye = new Xtruct(); |
| 349 | goodbye.string_thing = "Goodbye4"; |
| 350 | goodbye.byte_thing = 4; |
| 351 | goodbye.i32_thing = 4; |
| 352 | goodbye.i64_thing = Int64.make(0, 4); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 353 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 354 | var crazy = new Insanity(); |
| 355 | crazy.userMap = new IntMap< haxe.Int64>(); |
| 356 | crazy.userMap.set(Numberz.EIGHT, Int64.make(0,8)); |
| 357 | crazy.xtructs = new List<Xtruct>(); |
| 358 | crazy.xtructs.add(goodbye); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 359 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 360 | var looney = new Insanity(); |
| 361 | crazy.userMap.set(Numberz.FIVE, Int64.make(0,5)); |
| 362 | crazy.xtructs.add(hello); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 363 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 364 | var first_map = new IntMap< Insanity>(); |
| 365 | first_map.set(Numberz.TWO, crazy); |
| 366 | first_map.set(Numberz.THREE, crazy); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 367 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 368 | var second_map = new IntMap< Insanity>(); |
| 369 | second_map.set(Numberz.SIX, looney); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 370 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 371 | var insane = new Int64Map< IntMap< Insanity>>(); |
| 372 | insane.set( Int64.make(0,1), first_map); |
| 373 | insane.set( Int64.make(0,2), second_map); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 374 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 375 | return insane; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 376 | } |
| 377 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 378 | /** |
| 379 | * Prints 'testMulti()' |
| 380 | * @param byte arg0 - |
| 381 | * @param i32 arg1 - |
| 382 | * @param i64 arg2 - |
| 383 | * @param map<i16, string> arg3 - |
| 384 | * @param Numberz arg4 - |
| 385 | * @param UserId arg5 - |
| 386 | * @return Xtruct - returns an Xtruct |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 387 | * with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 388 | * and i64_thing = arg2 |
| 389 | * |
| 390 | * @param arg0 |
| 391 | * @param arg1 |
| 392 | * @param arg2 |
| 393 | * @param arg3 |
| 394 | * @param arg4 |
| 395 | * @param arg5 |
| 396 | */ |
| 397 | public function testMulti(arg0:haxe.Int32, arg1:haxe.Int32, arg2:haxe.Int64, |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 398 | arg3:IntMap<String>, arg4:Int, arg5:haxe.Int64):Xtruct |
| 399 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 400 | trace("testMulti()"); |
| 401 | var hello = new Xtruct(); |
| 402 | hello.string_thing = "Hello2"; |
| 403 | hello.byte_thing = arg0; |
| 404 | hello.i32_thing = arg1; |
| 405 | hello.i64_thing = arg2; |
| 406 | return hello; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 407 | } |
| 408 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 409 | /** |
| 410 | * Print 'testException(%s)' with arg as '%s' |
| 411 | * @param string arg - a string indication what type of exception to throw |
| 412 | * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg |
| 413 | * elsen if arg == "TException" throw TException |
| 414 | * else do not throw anything |
| 415 | * |
| 416 | * @param arg |
| 417 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 418 | public function testException(arg:String):Void |
| 419 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 420 | trace("testException(" + arg + ")"); |
| 421 | if (arg == "Xception") { |
| 422 | var x = new Xception(); |
| 423 | x.errorCode = 1001; |
| 424 | x.message = arg; |
| 425 | throw x; |
| 426 | }; |
| 427 | if (arg == "TException") { |
| 428 | throw new TException(); |
| 429 | }; |
| 430 | return; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 431 | } |
| 432 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 433 | /** |
| 434 | * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' |
| 435 | * @param string arg - a string indication what type of exception to throw |
| 436 | * if arg0 == "Xception" |
| 437 | * throw Xception with errorCode = 1001 and message = "This is an Xception" |
| 438 | * else if arg0 == "Xception2" |
| 439 | * throw Xception2 with errorCode = 2002 and message = "This is an Xception2" |
| 440 | * else do not throw anything |
| 441 | * @return Xtruct - an Xtruct with string_thing = arg1 |
| 442 | * |
| 443 | * @param arg0 |
| 444 | * @param arg1 |
| 445 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 446 | public function testMultiException(arg0:String, arg1:String):Xtruct |
| 447 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 448 | trace("testMultiException(" + arg0 + ", " + arg1 + ")"); |
| 449 | if (arg0 == "Xception") { |
| 450 | var x = new Xception(); |
| 451 | x.errorCode = 1001; |
| 452 | x.message = "This is an Xception"; |
| 453 | throw x; |
| 454 | } else if (arg0 == "Xception2") { |
| 455 | var x = new Xception2(); |
| 456 | x.errorCode = 2002; |
| 457 | x.struct_thing = new Xtruct(); |
| 458 | x.struct_thing.string_thing = "This is an Xception2"; |
| 459 | throw x; |
| 460 | }; |
| 461 | var result = new Xtruct(); |
| 462 | result.string_thing = arg1; |
| 463 | return result; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 464 | } |
| 465 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 466 | /** |
| 467 | * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' |
| 468 | * sleep 'secondsToSleep' |
| 469 | * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' |
| 470 | * @param i32 secondsToSleep - the number of seconds to sleep |
| 471 | * |
| 472 | * @param secondsToSleep |
| 473 | */ |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 474 | public function testOneway(secondsToSleep:haxe.Int32):Void |
| 475 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 476 | trace("testOneway(" + secondsToSleep + "), sleeping..."); |
| 477 | Sys.sleep(secondsToSleep); |
| 478 | trace("testOneway finished"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | public function testStop():Void |
| 482 | { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 483 | if (server != null) { |
| 484 | server.Stop(); |
| 485 | }; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 486 | } |
| 487 | } |