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