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