PageRenderTime 59ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/IronPython/IronPythonTest/BindTest.cs

#
C# | 1224 lines | 944 code | 255 blank | 25 comment | 16 complexity | 624456cb5468107c7a19f017d837c966 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.Runtime.InteropServices;
  19. using Microsoft.Scripting.Runtime;
  20. using Microsoft.Scripting.Utils;
  21. using IronPython.Runtime;
  22. using IronPython.Runtime.Types;
  23. namespace IronPythonTest {
  24. [Flags]
  25. public enum BindResult {
  26. None = 0,
  27. Bool = 1,
  28. Byte = 2,
  29. Char = 3,
  30. Decimal = 4,
  31. Double = 5,
  32. Float = 6,
  33. Int = 7,
  34. Long = 8,
  35. Object = 9,
  36. SByte = 10,
  37. Short = 11,
  38. String = 12,
  39. UInt = 13,
  40. ULong = 14,
  41. UShort = 15,
  42. Array = 0x1000,
  43. Out = 0x2000,
  44. Ref = 0x4000,
  45. }
  46. public class BindTest {
  47. public static object BoolValue = (bool)true;
  48. public static object ByteValue = (byte)0;
  49. public static object CharValue = (char)'\0';
  50. public static object DecimalValue = (decimal)0;
  51. public static object DoubleValue = (double)0;
  52. public static object FloatValue = (float)0;
  53. public static object IntValue = (int)0;
  54. public static object LongValue = (long)0;
  55. #if !SILVERLIGHT
  56. public static object ObjectValue = (object)new System.Collections.Hashtable();
  57. #else
  58. public static object ObjectValue = (object)new Dictionary<object, object>();
  59. #endif
  60. public static object SByteValue = (sbyte)0;
  61. public static object ShortValue = (short)0;
  62. public static object StringValue = (string)String.Empty;
  63. public static object UIntValue = (uint)0;
  64. public static object ULongValue = (ulong)0;
  65. public static object UShortValue = (ushort)0;
  66. public static BindResult Bind() { return BindResult.None; }
  67. public static BindResult Bind(bool value) { return BindResult.Bool; }
  68. public static BindResult Bind(byte value) { return BindResult.Byte; }
  69. public static BindResult Bind(char value) { return BindResult.Char; }
  70. public static BindResult Bind(decimal value) { return BindResult.Decimal; }
  71. public static BindResult Bind(double value) { return BindResult.Double; }
  72. public static BindResult Bind(float value) { return BindResult.Float; }
  73. public static BindResult Bind(int value) { return BindResult.Int; }
  74. public static BindResult Bind(long value) { return BindResult.Long; }
  75. public static BindResult Bind(object value) { return BindResult.Object; }
  76. public static BindResult Bind(sbyte value) { return BindResult.SByte; }
  77. public static BindResult Bind(short value) { return BindResult.Short; }
  78. public static BindResult Bind(string value) { return BindResult.String; }
  79. public static BindResult Bind(uint value) { return BindResult.UInt; }
  80. public static BindResult Bind(ulong value) { return BindResult.ULong; }
  81. public static BindResult Bind(ushort value) { return BindResult.UShort; }
  82. public static BindResult Bind(bool[] value) { return BindResult.Bool | BindResult.Array; }
  83. public static BindResult Bind(byte[] value) { return BindResult.Byte | BindResult.Array; }
  84. public static BindResult Bind(char[] value) { return BindResult.Char | BindResult.Array; }
  85. public static BindResult Bind(decimal[] value) { return BindResult.Decimal | BindResult.Array; }
  86. public static BindResult Bind(double[] value) { return BindResult.Double | BindResult.Array; }
  87. public static BindResult Bind(float[] value) { return BindResult.Float | BindResult.Array; }
  88. public static BindResult Bind(int[] value) { return BindResult.Int | BindResult.Array; }
  89. public static BindResult Bind(long[] value) { return BindResult.Long | BindResult.Array; }
  90. public static BindResult Bind(object[] value) { return BindResult.Object | BindResult.Array; }
  91. public static BindResult Bind(sbyte[] value) { return BindResult.SByte | BindResult.Array; }
  92. public static BindResult Bind(short[] value) { return BindResult.Short | BindResult.Array; }
  93. public static BindResult Bind(string[] value) { return BindResult.String | BindResult.Array; }
  94. public static BindResult Bind(uint[] value) { return BindResult.UInt | BindResult.Array; }
  95. public static BindResult Bind(ulong[] value) { return BindResult.ULong | BindResult.Array; }
  96. public static BindResult Bind(ushort[] value) { return BindResult.UShort | BindResult.Array; }
  97. public static BindResult Bind(out bool value) { value = false; return BindResult.Bool | BindResult.Out; }
  98. public static BindResult Bind(out byte value) { value = 0; return BindResult.Byte | BindResult.Out; }
  99. public static BindResult Bind(out char value) { value = '\0'; return BindResult.Char | BindResult.Out; }
  100. public static BindResult Bind(out decimal value) { value = 0; return BindResult.Decimal | BindResult.Out; }
  101. public static BindResult Bind(out double value) { value = 0; return BindResult.Double | BindResult.Out; }
  102. public static BindResult Bind(out float value) { value = 0; return BindResult.Float | BindResult.Out; }
  103. public static BindResult Bind(out int value) { value = 0; return BindResult.Int | BindResult.Out; }
  104. public static BindResult Bind(out long value) { value = 0; return BindResult.Long | BindResult.Out; }
  105. public static BindResult Bind(out object value) { value = null; return BindResult.Object | BindResult.Out; }
  106. public static BindResult Bind(out sbyte value) { value = 0; return BindResult.SByte | BindResult.Out; }
  107. public static BindResult Bind(out short value) { value = 0; return BindResult.Short | BindResult.Out; }
  108. public static BindResult Bind(out string value) { value = null; return BindResult.String | BindResult.Out; }
  109. public static BindResult Bind(out uint value) { value = 0; return BindResult.UInt | BindResult.Out; }
  110. public static BindResult Bind(out ulong value) { value = 0; return BindResult.ULong | BindResult.Out; }
  111. public static BindResult Bind(out ushort value) { value = 0; return BindResult.UShort | BindResult.Out; }
  112. public static BindResult BindRef(ref bool value) { value = false; return BindResult.Bool | BindResult.Ref; }
  113. public static BindResult BindRef(ref byte value) { value = 0; return BindResult.Byte | BindResult.Ref; }
  114. public static BindResult BindRef(ref char value) { value = '\0'; return BindResult.Char | BindResult.Ref; }
  115. public static BindResult BindRef(ref decimal value) { value = 0; return BindResult.Decimal | BindResult.Ref; }
  116. public static BindResult BindRef(ref double value) { value = 0; return BindResult.Double | BindResult.Ref; }
  117. public static BindResult BindRef(ref float value) { value = 0; return BindResult.Float | BindResult.Ref; }
  118. public static BindResult BindRef(ref int value) { value = 0; return BindResult.Int | BindResult.Ref; }
  119. public static BindResult BindRef(ref long value) { value = 0; return BindResult.Long | BindResult.Ref; }
  120. public static BindResult BindRef(ref object value) { value = null; return BindResult.Object | BindResult.Ref; }
  121. public static BindResult BindRef(ref sbyte value) { value = 0; return BindResult.SByte | BindResult.Ref; }
  122. public static BindResult BindRef(ref short value) { value = 0; return BindResult.Short | BindResult.Ref; }
  123. public static BindResult BindRef(ref string value) { value = null; return BindResult.String | BindResult.Ref; }
  124. public static BindResult BindRef(ref uint value) { value = 0; return BindResult.UInt | BindResult.Ref; }
  125. public static BindResult BindRef(ref ulong value) { value = 0; return BindResult.ULong | BindResult.Ref; }
  126. public static BindResult BindRef(ref ushort value) { value = 0; return BindResult.UShort | BindResult.Ref; }
  127. public static object ReturnTest(string type) {
  128. switch (type) {
  129. case "char": return 'a';
  130. case "object": return new object();
  131. case "null": return null;
  132. #if !SILVERLIGHT
  133. case "com":
  134. Type t = Type.GetTypeFromProgID("JScript");
  135. return Activator.CreateInstance(t);
  136. #endif
  137. }
  138. throw new NotImplementedException("unknown type");
  139. }
  140. }
  141. namespace DispatchHelpers {
  142. public class B { }
  143. public class D : B { }
  144. public interface I { }
  145. public class C1 : I { }
  146. public class C2 : I { }
  147. public enum Color { Red, Blue }
  148. }
  149. public class Dispatch {
  150. public static int Flag = 0;
  151. public void M1(int arg) { Flag = 101; }
  152. public void M1(DispatchHelpers.Color arg) { Flag = 201; }
  153. public void M2(int arg) { Flag = 102; }
  154. public void M2(int arg, params int[] arg2) { Flag = 202; }
  155. public void M3(int arg) { Flag = 103; }
  156. public void M3(int arg, int arg2) { Flag = 203; }
  157. public void M4(int arg) { Flag = 104; }
  158. public void M4(int arg, __arglist) { Flag = 204; }
  159. public void M5(float arg) { Flag = 105; }
  160. public void M5(double arg) { Flag = 205; }
  161. public void M6(char arg) { Flag = 106; }
  162. public void M6(string arg) { Flag = 206; }
  163. public void M7(int arg) { Flag = 107; }
  164. public void M7(params int[] args) { Flag = 207; }
  165. public void M8(int arg) { Flag = 108; }
  166. public void M8(ref int arg) { Flag = 208; arg = 999; }
  167. public void M10(ref int arg) { Flag = 210; arg = 999; }
  168. public void M11(int arg, int arg2) { Flag = 111; }
  169. public void M11(DispatchHelpers.Color arg, int arg2) { Flag = 211; }
  170. public void M12(int arg, DispatchHelpers.Color arg2) { Flag = 112; }
  171. public void M12(DispatchHelpers.Color arg, int arg2) { Flag = 212; }
  172. public void M20(DispatchHelpers.B arg) { Flag = 120; }
  173. public void M22(DispatchHelpers.B arg) { Flag = 122; }
  174. public void M22(DispatchHelpers.D arg) { Flag = 222; }
  175. public void M23(DispatchHelpers.I arg) { Flag = 123; }
  176. public void M23(DispatchHelpers.C2 arg) { Flag = 223; }
  177. public void M50(params DispatchHelpers.B[] args) { Flag = 150; }
  178. public void M51(params DispatchHelpers.B[] args) { Flag = 151; }
  179. public void M51(params DispatchHelpers.D[] args) { Flag = 251; }
  180. public void M60(int? arg) { Flag = 160; }
  181. public void M70(Dispatch arg) { Flag = 170; }
  182. public static void M71(Dispatch arg) { Flag = 171; }
  183. public static void M81(Dispatch arg, int arg2) { Flag = 181; }
  184. public void M81(int arg) { Flag = 281; }
  185. public static void M82(bool arg) { Flag = 182; }
  186. public static void M82(string arg) { Flag = 282; }
  187. public void M83(bool arg) { Flag = 183; }
  188. public void M83(string arg) { Flag = 283; }
  189. public void M90<T>(int arg) { Flag = 190; }
  190. public void M91(int arg) { Flag = 191; }
  191. public void M91<T>(int arg) { Flag = 291; }
  192. public static int M92(out int i, out int j, out int k, bool boolIn) {
  193. i = 1;
  194. j = 2;
  195. k = 3;
  196. Flag = 192;
  197. return boolIn ? 4 : 5;
  198. }
  199. public int M93(out int i, out int j, out int k, bool boolIn) {
  200. i = 1;
  201. j = 2;
  202. k = 3;
  203. Flag = 193;
  204. return boolIn ? 4 : 5;
  205. }
  206. public int M94(out int i, out int j, bool boolIn, out int k) {
  207. i = 1;
  208. j = 2;
  209. k = 3;
  210. Flag = 194;
  211. return boolIn ? 4 : 5;
  212. }
  213. public static int M95(out int i, out int j, bool boolIn, out int k) {
  214. i = 1;
  215. j = 2;
  216. k = 3;
  217. Flag = 195;
  218. return boolIn ? 4 : 5;
  219. }
  220. public static int M96(out int x, out int j, params int[] extras) {
  221. x = 1;
  222. j = 2;
  223. int res = 0;
  224. for (int i = 0; i < extras.Length; i++) res += extras[i];
  225. Flag = 196;
  226. return res;
  227. }
  228. public int M97(out int x, out int j, params int[] extras) {
  229. x = 1;
  230. j = 2;
  231. int res = 0;
  232. for (int i = 0; i < extras.Length; i++) res += extras[i];
  233. Flag = 197;
  234. return res;
  235. }
  236. public void M98(string a, string b, string c, string d, out int x, ref Dispatch di) {
  237. x = Convert.ToInt32(a) + Convert.ToInt32(b) + Convert.ToInt32(c) + Convert.ToInt32(d);
  238. di = this;
  239. Flag = 198;
  240. }
  241. public Single P01 {
  242. get; set;
  243. }
  244. }
  245. public class DispatchBase {
  246. public virtual void M1(int arg) { Dispatch.Flag = 101; }
  247. public virtual void M2(int arg) { Dispatch.Flag = 102; }
  248. public virtual void M3(int arg) { Dispatch.Flag = 103; }
  249. public void M4(int arg) { Dispatch.Flag = 104; }
  250. public virtual void M5(int arg) { Dispatch.Flag = 105; }
  251. public virtual void M6(int arg) { Dispatch.Flag = 106; }
  252. }
  253. public class DispatchDerived : DispatchBase {
  254. public override void M1(int arg) { Dispatch.Flag = 201; }
  255. public virtual void M2(DispatchHelpers.Color arg) { Dispatch.Flag = 202; }
  256. public virtual void M3(string arg) { Dispatch.Flag = 203; }
  257. public void M4(string arg) { Dispatch.Flag = 204; }
  258. public new virtual void M5(int arg) { Dispatch.Flag = 205; }
  259. }
  260. public class ConversionDispatch {
  261. public object Array(object[] arr) {
  262. return arr;
  263. }
  264. public object IntArray(int[] arr) {
  265. return arr;
  266. }
  267. public object StringArray(string[] arr) {
  268. return arr;
  269. }
  270. public object Enumerable(IEnumerable<object> enm) {
  271. return enm;
  272. }
  273. public object StringEnumerable(IEnumerable<string> enm) {
  274. return enm;
  275. }
  276. public object StringEnumerator(IEnumerator<string> enm) {
  277. return enm;
  278. }
  279. public object ObjectEnumerator(IEnumerator<object> enm) {
  280. return enm;
  281. }
  282. public object NonGenericEnumerator(IEnumerator enm) {
  283. return enm;
  284. }
  285. public object IntEnumerable(IEnumerable<int> enm) {
  286. return enm;
  287. }
  288. public object ObjIList(IList<object> list) {
  289. return list;
  290. }
  291. public object IntIList(IList<int> list) {
  292. return list;
  293. }
  294. public object StringIList(IList<string> list) {
  295. return list;
  296. }
  297. public object ObjList(List<object> list) {
  298. return list;
  299. }
  300. public object IntList(List<int> list) {
  301. return list;
  302. }
  303. public object StringList(List<string> list) {
  304. return list;
  305. }
  306. public object DictTest(IDictionary<object, object> dict) {
  307. return dict;
  308. }
  309. public object IntDictTest(IDictionary<int, int> dict) {
  310. return dict;
  311. }
  312. public object StringDictTest(IDictionary<string, string> dict) {
  313. return dict;
  314. }
  315. public object MixedDictTest(IDictionary<string, int> dict) {
  316. return dict;
  317. }
  318. #if !SILVERLIGHT
  319. public object ArrayList(System.Collections.ArrayList list) {
  320. return list;
  321. }
  322. public object HashtableTest(Hashtable dict) {
  323. return dict;
  324. }
  325. #endif
  326. }
  327. public class MixedDispatch {
  328. public string instance_name;
  329. public string called;
  330. public MixedDispatch(string name) {
  331. instance_name = name;
  332. }
  333. public static object Combine(MixedDispatch md1, MixedDispatch md2) {
  334. MixedDispatch md_res = new MixedDispatch(md1.instance_name + md2.instance_name);
  335. md_res.called = "static";
  336. return md_res;
  337. }
  338. public object Combine(MixedDispatch other) {
  339. MixedDispatch md_res = new MixedDispatch(other.instance_name + instance_name);
  340. md_res.called = "instance";
  341. return md_res;
  342. }
  343. public object Combine2(MixedDispatch other) {
  344. MixedDispatch md_res = new MixedDispatch(other.instance_name + instance_name);
  345. md_res.called = "instance";
  346. return md_res;
  347. }
  348. public static object Combine2(MixedDispatch md1, MixedDispatch md2) {
  349. MixedDispatch md_res = new MixedDispatch(md1.instance_name + md2.instance_name);
  350. md_res.called = "static";
  351. return md_res;
  352. }
  353. public object Combine2(MixedDispatch other, MixedDispatch other2, MixedDispatch other3) {
  354. MixedDispatch md_res = new MixedDispatch(other.instance_name + instance_name + other2.instance_name + other3.instance_name);
  355. md_res.called = "instance_three";
  356. return md_res;
  357. }
  358. }
  359. public class FieldTest {
  360. public IList<Type> Field;
  361. }
  362. public class ComparisonTest {
  363. public delegate void Reporter(string name);
  364. public double value;
  365. public static Reporter report;
  366. public ComparisonTest(double value) {
  367. this.value = value;
  368. }
  369. public override string ToString() {
  370. return string.Format(System.Globalization.CultureInfo.InvariantCulture, "ct<{0}>", value);
  371. }
  372. public static bool operator <(ComparisonTest x, ComparisonTest y) {
  373. Report("<", x, y);
  374. return x.value < y.value;
  375. }
  376. public static bool operator >(ComparisonTest x, ComparisonTest y) {
  377. Report(">", x, y);
  378. return x.value > y.value;
  379. }
  380. public static bool operator <=(ComparisonTest x, ComparisonTest y) {
  381. Report("<=", x, y);
  382. return x.value <= y.value;
  383. }
  384. public static bool operator >=(ComparisonTest x, ComparisonTest y) {
  385. Report(">=", x, y);
  386. return x.value >= y.value;
  387. }
  388. private static void Report(string op, ComparisonTest x, ComparisonTest y) {
  389. if (report != null) {
  390. report(string.Format("{0} on [{1}, {2}]", op, x, y));
  391. }
  392. }
  393. }
  394. public enum BigEnum : long {
  395. None,
  396. BigValue = UInt32.MaxValue,
  397. }
  398. public class DefaultValueTest {
  399. public BindResult Test_Enum([DefaultParameterValue(BindResult.Bool)] BindResult param) {
  400. return param;
  401. }
  402. public BigEnum Test_BigEnum([DefaultParameterValue(BigEnum.BigValue)] BigEnum param) {
  403. return param;
  404. }
  405. public string Test_String([DefaultParameterValue("Hello World")] string param) {
  406. return param;
  407. }
  408. public int Test_Int([DefaultParameterValue(5)] int param) {
  409. return param;
  410. }
  411. public uint Test_UInt([DefaultParameterValue(uint.MaxValue)] uint param) {
  412. return param;
  413. }
  414. public bool Test_Bool([DefaultParameterValue(true)] bool param) {
  415. return param;
  416. }
  417. public char Test_Char([DefaultParameterValue('A')] char param) {
  418. return param;
  419. }
  420. public byte Test_Byte([DefaultParameterValue((byte)2)] byte param) {
  421. return param;
  422. }
  423. public sbyte Test_SByte([DefaultParameterValue((sbyte)2)] sbyte param) {
  424. return param;
  425. }
  426. public short Test_Short([DefaultParameterValue((short)2)] short param) {
  427. return param;
  428. }
  429. public ushort Test_UShort([DefaultParameterValue((ushort)2)] ushort param) {
  430. return param;
  431. }
  432. public long Test_Long([DefaultParameterValue(long.MaxValue)] long param) {
  433. return param;
  434. }
  435. public ulong Test_ULong([DefaultParameterValue(ulong.MaxValue)] ulong param) {
  436. return param;
  437. }
  438. public string Test_ByRef_Object([In, Optional] ref object o1, [In, Optional] ref object o2, [In, Optional] ref object o3) {
  439. return (o1 == null ? "(null)" : o1.ToString()) + "; " +
  440. (o2 == null ? "(null)" : o2.ToString()) + "; " +
  441. (o3 == null ? "(null)" : o3.ToString());
  442. }
  443. public string Test_Default_ValueType([DefaultParameterValue(1)] object o) {
  444. return o == null ? "(null)" : o.ToString();
  445. }
  446. public string Test_Default_Cast([Optional, DefaultParameterValue(1)]ref object o) {
  447. return o == null ? "(null)" : o.ToString();
  448. }
  449. }
  450. public struct Structure {
  451. public int a;
  452. public float b;
  453. public double c;
  454. public decimal d;
  455. public string e;
  456. #if !SILVERLIGHT
  457. public Hashtable f;
  458. #else
  459. public Dictionary<object, object> f;
  460. #endif
  461. }
  462. public class MissingValueTest {
  463. public static string Test_1([In, Optional] bool o) { return "(bool)" + o.ToString(); }
  464. public static string Test_2([In, Optional] ref bool o) { return "(bool)" + o.ToString(); }
  465. public static string Test_3([In, Optional] sbyte o) { return "(sbyte)" + o.ToString(); }
  466. public static string Test_4([In, Optional] ref sbyte o) { return "(sbyte)" + o.ToString(); }
  467. public static string Test_5([In, Optional] byte o) { return "(byte)" + o.ToString(); }
  468. public static string Test_6([In, Optional] ref byte o) { return "(byte)" + o.ToString(); }
  469. public static string Test_7([In, Optional] short o) { return "(short)" + o.ToString(); }
  470. public static string Test_8([In, Optional] ref short o) { return "(short)" + o.ToString(); }
  471. public static string Test_9([In, Optional] ushort o) { return "(ushort)" + o.ToString(); }
  472. public static string Test_10([In, Optional] ref ushort o) { return "(ushort)" + o.ToString(); }
  473. public static string Test_11([In, Optional] int o) { return "(int)" + o.ToString(); }
  474. public static string Test_12([In, Optional] ref int o) { return "(int)" + o.ToString(); }
  475. public static string Test_13([In, Optional] uint o) { return "(uint)" + o.ToString(); }
  476. public static string Test_14([In, Optional] ref uint o) { return "(uint)" + o.ToString(); }
  477. public static string Test_15([In, Optional] long o) { return "(long)" + o.ToString(); }
  478. public static string Test_16([In, Optional] ref long o) { return "(long)" + o.ToString(); }
  479. public static string Test_17([In, Optional] ulong o) { return "(ulong)" + o.ToString(); }
  480. public static string Test_18([In, Optional] ref ulong o) { return "(ulong)" + o.ToString(); }
  481. public static string Test_19([In, Optional] decimal o) { return "(decimal)" + o.ToString(); }
  482. public static string Test_20([In, Optional] ref decimal o) { return "(decimal)" + o.ToString(); }
  483. public static string Test_21([In, Optional] float o) { return "(float)" + o.ToString(); }
  484. public static string Test_22([In, Optional] ref float o) { return "(float)" + o.ToString(); }
  485. public static string Test_23([In, Optional] double o) { return "(double)" + o.ToString(); }
  486. public static string Test_24([In, Optional] ref double o) { return "(double)" + o.ToString(); }
  487. public static string Test_25([In, Optional] DaysByte o) { return "(DaysByte)" + o.ToString(); }
  488. public static string Test_26([In, Optional] ref DaysByte o) { return "(DaysByte)" + o.ToString(); }
  489. public static string Test_27([In, Optional] DaysSByte o) { return "(DaysSByte)" + o.ToString(); }
  490. public static string Test_28([In, Optional] ref DaysSByte o) { return "(DaysSByte)" + o.ToString(); }
  491. public static string Test_29([In, Optional] DaysShort o) { return "(DaysShort)" + o.ToString(); }
  492. public static string Test_30([In, Optional] ref DaysShort o) { return "(DaysShort)" + o.ToString(); }
  493. public static string Test_31([In, Optional] DaysUShort o) { return "(DaysUShort)" + o.ToString(); }
  494. public static string Test_32([In, Optional] ref DaysUShort o) { return "(DaysUShort)" + o.ToString(); }
  495. public static string Test_33([In, Optional] DaysInt o) { return "(DaysInt)" + o.ToString(); }
  496. public static string Test_34([In, Optional] ref DaysInt o) { return "(DaysInt)" + o.ToString(); }
  497. public static string Test_35([In, Optional] DaysUInt o) { return "(DaysUInt)" + o.ToString(); }
  498. public static string Test_36([In, Optional] ref DaysUInt o) { return "(DaysUInt)" + o.ToString(); }
  499. public static string Test_37([In, Optional] DaysLong o) { return "(DaysLong)" + o.ToString(); }
  500. public static string Test_38([In, Optional] ref DaysLong o) { return "(DaysLong)" + o.ToString(); }
  501. public static string Test_39([In, Optional] DaysULong o) { return "(DaysULong)" + o.ToString(); }
  502. public static string Test_40([In, Optional] ref DaysULong o) { return "(DaysULong)" + o.ToString(); }
  503. public static string Test_41([In, Optional] char o) { return "(char)" + o.ToString(); }
  504. public static string Test_42([In, Optional] ref char o) { return "(char)" + o.ToString(); }
  505. public static string Test_43([In, Optional] Structure o) { return "(Structure)" + o.ToString(); }
  506. public static string Test_44([In, Optional] ref Structure o) { return "(Structure)" + o.ToString(); }
  507. public static string Test_45([In, Optional] EnumSByte o) { return "(EnumSByte)" + o.ToString(); }
  508. public static string Test_46([In, Optional] ref EnumSByte o) { return "(EnumSByte)" + o.ToString(); }
  509. public static string Test_47([In, Optional] EnumByte o) { return "(EnumByte)" + o.ToString(); }
  510. public static string Test_48([In, Optional] ref EnumByte o) { return "(EnumByte)" + o.ToString(); }
  511. public static string Test_49([In, Optional] EnumShort o) { return "(EnumShort)" + o.ToString(); }
  512. public static string Test_50([In, Optional] ref EnumShort o) { return "(EnumShort)" + o.ToString(); }
  513. public static string Test_51([In, Optional] EnumUShort o) { return "(EnumUShort)" + o.ToString(); }
  514. public static string Test_52([In, Optional] ref EnumUShort o) { return "(EnumUShort)" + o.ToString(); }
  515. public static string Test_53([In, Optional] EnumInt o) { return "(EnumInt)" + o.ToString(); }
  516. public static string Test_54([In, Optional] ref EnumInt o) { return "(EnumInt)" + o.ToString(); }
  517. public static string Test_55([In, Optional] EnumUInt o) { return "(EnumUInt)" + o.ToString(); }
  518. public static string Test_56([In, Optional] ref EnumUInt o) { return "(EnumUInt)" + o.ToString(); }
  519. public static string Test_57([In, Optional] EnumLong o) { return "(EnumLong)" + o.ToString(); }
  520. public static string Test_58([In, Optional] ref EnumLong o) { return "(EnumLong)" + o.ToString(); }
  521. public static string Test_59([In, Optional] EnumULong o) { return "(EnumULong)" + o.ToString(); }
  522. public static string Test_60([In, Optional] ref EnumULong o) { return "(EnumULong)" + o.ToString(); }
  523. public static string Test_61([In, Optional] string o) { return "(string)" + (o == null ? "(null)" : o); }
  524. public static string Test_62([In, Optional] ref string o) { return "(string)" + (o == null ? "(null)" : o); }
  525. public static string Test_63([In, Optional] object o) { return "(object)" + (o == null ? "(null)" : o.ToString()); }
  526. public static string Test_64([In, Optional] ref object o) { return "(object)" + (o == null ? "(null)" : o.ToString()); }
  527. public static string Test_65([In, Optional] MissingValueTest o) { return "(MissingValueTest)" + (o == null ? "(null)" : o.ToString()); }
  528. public static string Test_66([In, Optional] ref MissingValueTest o) { return "(MissingValueTest)" + (o == null ? "(null)" : o.ToString()); }
  529. }
  530. public class DispatchAgain {
  531. // ***************** OptimizedFunctionX *****************
  532. public string IM0() { return "IM0"; }
  533. public string IM1(int arg1) { return "IM1"; }
  534. public string IM2(int arg1, int arg2) { return "IM2"; }
  535. public string IM3(int arg1, int arg2, int arg3) { return "IM3"; }
  536. public string IM4(int arg1, int arg2, int arg3, int arg4) { return "IM4"; }
  537. public string IM5(int arg1, int arg2, int arg3, int arg4, int arg5) { return "IM5"; }
  538. public string IM6(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { return "IM6"; }
  539. public static string SM0() { return "SM0"; }
  540. public static string SM1(int arg1) { return "SM1"; }
  541. public static string SM2(int arg1, int arg2) { return "SM2"; }
  542. public static string SM3(int arg1, int arg2, int arg3) { return "SM3"; }
  543. public static string SM4(int arg1, int arg2, int arg3, int arg4) { return "SM4"; }
  544. public static string SM5(int arg1, int arg2, int arg3, int arg4, int arg5) { return "SM5"; }
  545. public static string SM6(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { return "SM6"; }
  546. // ***************** OptimizedFunctionN *****************
  547. public string IPM0(params int[] args) { return "IPM0-" + args.Length; }
  548. public static string SPM0(params int[] args) { return "SPM0-" + args.Length; }
  549. // suppose to be optimized?
  550. public string IPM1(int arg1, params int[] args) { return "IPM1-" + args.Length; }
  551. public static string SPM1(int arg1, params int[] args) { return "SPM1-" + args.Length; }
  552. // ***************** OptimizedFunctionAny *****************
  553. // 1. miss 1, 2 arguments, and no params
  554. public string IDM0() { return "IDM0-0"; }
  555. public string IDM0(int arg1, int arg2, int arg3) { return "IDM0-3"; }
  556. public string IDM0(int arg1, int arg2, int arg3, int arg4) { return "IDM0-4"; }
  557. public static string SDM0() { return "SDM0-0"; }
  558. public static string SDM0(int arg1, int arg2, int arg3) { return "SDM0-3"; }
  559. // 2. miss 0, 3, 4 arguments, but have params
  560. public string IDM1(int arg1) { return "IDM1-1"; }
  561. public string IDM1(params int[] args) { return "IDM1-x"; }
  562. public static string SDM1(int arg1) { return "SDM1-1"; }
  563. public static string SDM1(params int[] args) { return "SDM1-x"; }
  564. public string IDM4(int arg1, int arg2) { return "IDM4-2"; }
  565. public string IDM4(params int[] args) { return "IDM4-x"; }
  566. public static string SDM4(int arg1, int arg2) { return "SDM4-2"; }
  567. public static string SDM4(params int[] args) { return "SDM4-x"; }
  568. // 3. this is optimizated, and have all cases without params
  569. public string IDM2() { return "IDM2-0"; }
  570. public string IDM2(int arg1) { return "IDM2-1"; }
  571. public string IDM2(int arg1, int arg2) { return "IDM2-2"; }
  572. public string IDM2(int arg1, int arg2, int arg3) { return "IDM2-3"; }
  573. public string IDM2(int arg1, int arg2, int arg3, int arg4) { return "IDM2-4"; }
  574. public static string SDM2() { return "SDM2-0"; }
  575. public static string SDM2(int arg1) { return "SDM2-1"; }
  576. public static string SDM2(int arg1, int arg2) { return "SDM2-2"; }
  577. public static string SDM2(int arg1, int arg2, int arg3) { return "SDM2-3"; }
  578. public static string SDM2(int arg1, int arg2, int arg3, int arg4) { return "SDM2-4"; }
  579. public static string SDM2(int arg1, int arg2, int arg3, int arg4, int arg5) { return "SDM2-5"; }
  580. // 4. this is not optimized
  581. public string IDM5() { return "IDM5-0"; }
  582. public string IDM5(int arg1, int arg2, int arg3, int arg4, int arg5) { return "IDM5-5"; }
  583. public static string SDM5() { return "SDM5-0"; }
  584. public static string SDM5(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { return "SDM5-6"; }
  585. // 5. this is optimizated, and have all cases, with params
  586. public string IDM3() { return "IDM3-0"; }
  587. public string IDM3(int arg1) { return "IDM3-1"; }
  588. public string IDM3(int arg1, int arg2) { return "IDM3-2"; }
  589. public string IDM3(int arg1, int arg2, int arg3) { return "IDM3-3"; }
  590. public string IDM3(int arg1, int arg2, int arg3, int arg4) { return "IDM3-4"; }
  591. public string IDM3(params int[] args) { return "IDM3-x"; }
  592. public static string SDM3() { return "SDM3-0"; }
  593. public static string SDM3(int arg1) { return "SDM3-1"; }
  594. public static string SDM3(int arg1, int arg2) { return "SDM3-2"; }
  595. public static string SDM3(int arg1, int arg2, int arg3) { return "SDM3-3"; }
  596. public static string SDM3(int arg1, int arg2, int arg3, int arg4) { return "SDM3-4"; }
  597. public static string SDM3(int arg1, int arg2, int arg3, int arg4, int arg5) { return "SDM3-5"; }
  598. public static string SDM3(params int[] args) { return "SDM3-x"; }
  599. }
  600. public class MultiCall {
  601. public int M0(int arg) { return 1; }
  602. public int M0(long arg) { return 2; }
  603. public int M1(int arg) { return 1; }
  604. public int M1(long arg) { return 2; }
  605. public int M1(object arg) { return 3; }
  606. public int M2(int arg1, int arg2) { return 1; }
  607. public int M2(long arg1, int arg2) { return 2; }
  608. public int M2(int arg1, long arg2) { return 3; }
  609. public int M2(long arg1, long arg2) { return 4; }
  610. public int M2(object arg1, object arg2) { return 5; }
  611. public int M4(int arg1, int arg2, int arg3, int arg4) { return 1; }
  612. public int M4(object arg1, object arg2, object arg3, object arg4) { return 2; }
  613. public int M5(DispatchHelpers.B arg1, DispatchHelpers.B args) { return 1; }
  614. public int M5(DispatchHelpers.D arg1, DispatchHelpers.B args) { return 2; }
  615. public int M5(object arg1, object args) { return 3; }
  616. public int M6(DispatchHelpers.B arg1, DispatchHelpers.B args) { return 1; }
  617. public int M6(DispatchHelpers.B arg1, DispatchHelpers.D args) { return 2; }
  618. public int M6(object arg1, DispatchHelpers.D args) { return 3; }
  619. public int M7(DispatchHelpers.B arg1, DispatchHelpers.B args) { return 1; }
  620. public int M7(DispatchHelpers.B arg1, DispatchHelpers.D args) { return 2; }
  621. public int M7(DispatchHelpers.D arg1, DispatchHelpers.B args) { return 3; }
  622. public int M7(DispatchHelpers.D arg1, DispatchHelpers.D args) { return 4; }
  623. public int M8(int arg1, int arg2) { return 1; }
  624. public int M8(DispatchHelpers.B arg1, DispatchHelpers.B args) { return 2; }
  625. public int M8(object arg1, object arg2) { return 3; }
  626. }
  627. public class GenericTypeInference {
  628. public static PythonType M0<T>(T x) {
  629. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  630. }
  631. public static PythonType M0CC<T>(CodeContext context, T x) {
  632. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  633. }
  634. public static PythonType M1<T>(T x, T y) {
  635. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  636. }
  637. public static PythonType M2<T>(T x, T y, T z) {
  638. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  639. }
  640. public static PythonType M3<T>(params T[] x) {
  641. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  642. }
  643. public static PythonType M4<T>(T x, params T[] args) {
  644. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  645. }
  646. public static PythonType M5<T>(T x) where T : class {
  647. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  648. }
  649. public static PythonType M6<T>(T x) where T : struct {
  650. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  651. }
  652. public static PythonType M7<T>(T x) where T : IList {
  653. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  654. }
  655. public static PythonTuple M8<T0, T1>(T0 x, T1 y) where T0 : T1 {
  656. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  657. }
  658. public static PythonTuple M9<T0, T1>(object x, T1 y) where T0 : T1 {
  659. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  660. }
  661. public static PythonTuple M9b<T0, T1>(T0 x, object y) where T0 : T1 {
  662. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  663. }
  664. public static PythonTuple M10<T0, T1, T2>(T0 x, T1 y, T2 z)
  665. where T0 : T1
  666. where T1 : T2 {
  667. return PythonTuple.MakeTuple(
  668. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  669. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  670. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  671. );
  672. }
  673. public static PythonTuple M10c<T0, T1, T2>(T0 x, T1 y, T2 z)
  674. where T0 : T1
  675. where T1 : class {
  676. return PythonTuple.MakeTuple(
  677. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  678. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  679. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  680. );
  681. }
  682. public static PythonTuple M10IList<T0, T1, T2>(T0 x, T1 y, T2 z)
  683. where T0 : T1
  684. where T1 : IList {
  685. return PythonTuple.MakeTuple(
  686. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  687. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  688. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  689. );
  690. }
  691. public static PythonTuple M10PythonTuple<T0, T1, T2>(T0 x, T1 y, T2 z)
  692. where T0 : T1
  693. where T1 : PythonTuple {
  694. return PythonTuple.MakeTuple(
  695. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  696. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  697. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  698. );
  699. }
  700. public static PythonType M11<T>(object x) {
  701. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  702. }
  703. public static PythonType M12<T0, T1>(T0 x, object y) {
  704. return DynamicHelpers.GetPythonTypeFromType(typeof(T0));
  705. }
  706. public static PythonTuple M13<T>(T x, Func<T> y) {
  707. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)), y());
  708. }
  709. public static PythonType M14<T>(T x, Action<T> y) {
  710. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  711. }
  712. public static PythonTuple M15<T>(T x, IList<T> y) {
  713. PythonTuple res = PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)));
  714. res += PythonTuple.Make(y);
  715. return res;
  716. }
  717. public static PythonTuple M16<T>(T x, Dictionary<T, IList<T>> y) {
  718. PythonTuple res = PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)));
  719. res += PythonTuple.Make(y);
  720. return res;
  721. }
  722. public static PythonType M17<T>(T x, IEnumerable<T> y) {
  723. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  724. }
  725. public static PythonType M18<T>(T x) where T : IEnumerable<T> {
  726. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  727. }
  728. public static PythonTuple M19<T0, T1>(T0 x, T1 y) where T0 : IList<T1> {
  729. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  730. }
  731. public static PythonTuple M20<T0, T1>(T0 x, T1 y) {
  732. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  733. }
  734. public static PythonType M21<T>(IEnumerable<T> x) {
  735. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  736. }
  737. // overloads like Enumerable.Where<T>(...)
  738. public static PythonTuple M22<T>(IEnumerable<T> x, Func<T, bool> y) {
  739. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)), ScriptingRuntimeHelpers.True);
  740. }
  741. public static PythonTuple M22<T>(IEnumerable<T> x, Func<T, int, bool> y) {
  742. M23(new List<int>());
  743. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)), ScriptingRuntimeHelpers.False);
  744. }
  745. public static PythonType M23<T>(List<T> x) {
  746. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  747. }
  748. public static PythonType M24<T>(List<List<T>> x) {
  749. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  750. }
  751. public static PythonType M25<T>(Dictionary<T, T> x) {
  752. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  753. }
  754. public static PythonType M26<T>(List<T> x) where T : class {
  755. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  756. }
  757. public static PythonType M27<T>(List<T> x) where T : struct {
  758. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  759. }
  760. public static PythonType M28<T>(List<T> x) where T : new() {
  761. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  762. }
  763. public static PythonType M29<T>(Dictionary<Dictionary<T, T>, Dictionary<T, T>> x) {
  764. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  765. }
  766. public static PythonType M30<T>(Func<T, bool> x) where T : struct {
  767. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  768. }
  769. public static PythonType M31<T>(Func<T, bool> x) where T : IList {
  770. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  771. }
  772. public static PythonType M32<T>(List<T> x) where T : new() {
  773. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  774. }
  775. public static PythonType M33<T>(List<T> x) where T : class {
  776. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  777. }
  778. public static PythonType M34<T>(IList<T> x, IList<T> y) {
  779. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  780. }
  781. public static PythonType M35<T>(IList<T> x) {
  782. return DynamicHelpers.GetPythonTypeFromType(typeof(IList<T>));
  783. }
  784. public static PythonType M35<T>(T[] x) {
  785. return DynamicHelpers.GetPythonTypeFromType(typeof(T[]));
  786. }
  787. }
  788. public class SelfEnumerable : IEnumerable<SelfEnumerable> {
  789. #region IEnumerable<Test> Members
  790. IEnumerator<SelfEnumerable> IEnumerable<SelfEnumerable>.GetEnumerator() {
  791. throw new NotImplementedException();
  792. }
  793. #endregion
  794. #region IEnumerable Members
  795. IEnumerator IEnumerable.GetEnumerator() {
  796. throw new NotImplementedException();
  797. }
  798. #endregion
  799. }
  800. public class GenericTypeInferenceInstance {
  801. public PythonType MInst<T>(T x) {
  802. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  803. }
  804. public PythonType M0<T>(T x) {
  805. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  806. }
  807. public PythonType M0CC<T>(CodeContext context, T x) {
  808. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  809. }
  810. public PythonType M1<T>(T x, T y) {
  811. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  812. }
  813. public PythonType M2<T>(T x, T y, T z) {
  814. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  815. }
  816. public PythonType M3<T>(params T[] x) {
  817. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  818. }
  819. public PythonType M4<T>(T x, params T[] args) {
  820. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  821. }
  822. public PythonType M5<T>(T x) where T : class {
  823. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  824. }
  825. public PythonType M6<T>(T x) where T : struct {
  826. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  827. }
  828. public PythonType M7<T>(T x) where T : IList {
  829. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  830. }
  831. public PythonTuple M8<T0, T1>(T0 x, T1 y) where T0 : T1 {
  832. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  833. }
  834. public PythonTuple M9<T0, T1>(object x, T1 y) where T0 : T1 {
  835. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  836. }
  837. public PythonTuple M9b<T0, T1>(T0 x, object y) where T0 : T1 {
  838. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  839. }
  840. public PythonTuple M10<T0, T1, T2>(T0 x, T1 y, T2 z)
  841. where T0 : T1
  842. where T1 : T2 {
  843. return PythonTuple.MakeTuple(
  844. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  845. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  846. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  847. );
  848. }
  849. public PythonTuple M10c<T0, T1, T2>(T0 x, T1 y, T2 z)
  850. where T0 : T1
  851. where T1 : class {
  852. return PythonTuple.MakeTuple(
  853. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  854. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  855. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  856. );
  857. }
  858. public PythonTuple M10IList<T0, T1, T2>(T0 x, T1 y, T2 z)
  859. where T0 : T1
  860. where T1 : IList {
  861. return PythonTuple.MakeTuple(
  862. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  863. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  864. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  865. );
  866. }
  867. public PythonTuple M10PythonTuple<T0, T1, T2>(T0 x, T1 y, T2 z)
  868. where T0 : T1
  869. where T1 : PythonTuple {
  870. return PythonTuple.MakeTuple(
  871. DynamicHelpers.GetPythonTypeFromType(typeof(T0)),
  872. DynamicHelpers.GetPythonTypeFromType(typeof(T1)),
  873. DynamicHelpers.GetPythonTypeFromType(typeof(T2))
  874. );
  875. }
  876. public PythonType M11<T>(object x) {
  877. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  878. }
  879. public PythonType M12<T0, T1>(T0 x, object y) {
  880. return DynamicHelpers.GetPythonTypeFromType(typeof(T0));
  881. }
  882. public PythonTuple M13<T>(T x, Func<T> y) {
  883. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)), y());
  884. }
  885. public PythonType M14<T>(T x, Action<T> y) {
  886. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  887. }
  888. public PythonTuple M15<T>(T x, IList<T> y) {
  889. PythonTuple res = PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)));
  890. res += PythonTuple.Make(y);
  891. return res;
  892. }
  893. public PythonTuple M16<T>(T x, Dictionary<T, IList<T>> y) {
  894. PythonTuple res = PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)));
  895. res += PythonTuple.Make(y);
  896. return res;
  897. }
  898. public PythonType M17<T>(T x, IEnumerable<T> y) {
  899. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  900. }
  901. public PythonType M18<T>(T x) where T : IEnumerable<T> {
  902. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  903. }
  904. public PythonTuple M19<T0, T1>(T0 x, T1 y) where T0 : IList<T1> {
  905. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  906. }
  907. public PythonTuple M20<T0, T1>(T0 x, T1 y) {
  908. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T0)), DynamicHelpers.GetPythonTypeFromType(typeof(T1)));
  909. }
  910. public PythonType M21<T>(IEnumerable<T> x) {
  911. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  912. }
  913. // overloads like Enumerable.Where<T>(...)
  914. public PythonTuple M22<T>(IEnumerable<T> x, Func<T, bool> y) {
  915. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)), ScriptingRuntimeHelpers.True);
  916. }
  917. public PythonTuple M22<T>(IEnumerable<T> x, Func<T, int, bool> y) {
  918. M23(new List<int>());
  919. return PythonTuple.MakeTuple(DynamicHelpers.GetPythonTypeFromType(typeof(T)), ScriptingRuntimeHelpers.False);
  920. }
  921. public PythonType M23<T>(List<T> x) {
  922. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  923. }
  924. public PythonType M24<T>(List<List<T>> x) {
  925. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  926. }
  927. public PythonType M25<T>(Dictionary<T, T> x) {
  928. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  929. }
  930. public PythonType M26<T>(List<T> x) where T : class {
  931. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  932. }
  933. public PythonType M27<T>(List<T> x) where T : struct {
  934. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  935. }
  936. public PythonType M28<T>(List<T> x) where T : new() {
  937. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  938. }
  939. public PythonType M29<T>(Dictionary<Dictionary<T, T>, Dictionary<T, T>> x) {
  940. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  941. }
  942. public PythonType M30<T>(Func<T, bool> x) where T : struct {
  943. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  944. }
  945. public PythonType M31<T>(Func<T, bool> x) where T : IList {
  946. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  947. }
  948. public PythonType M32<T>(List<T> x) where T : new() {
  949. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  950. }
  951. public PythonType M33<T>(List<T> x) where T : class {
  952. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  953. }
  954. public PythonType M34<T>(IList<T> x, IList<T> y) {
  955. return DynamicHelpers.GetPythonTypeFromType(typeof(T));
  956. }
  957. public static PythonType M35<T>(IList<T> x) {
  958. return DynamicHelpers.GetPythonTypeFromType(typeof(IList<T>));
  959. }
  960. public static PythonType M35<T>(T[] x) {
  961. return DynamicHelpers.GetPythonTypeFromType(typeof(T[]));
  962. }
  963. }
  964. public class WithCompare {
  965. public static bool Compare(object x, object y) {
  966. return true;
  967. }
  968. }
  969. }