ToLua_System_Enum.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using LuaInterface;
  3. public class ToLua_System_Enum
  4. {
  5. public static string ToIntDefined =
  6. @" try
  7. {
  8. object arg0 = ToLua.CheckObject<System.Enum>(L, 1);
  9. int ret = Convert.ToInt32(arg0);
  10. LuaDLL.lua_pushinteger(L, ret);
  11. return 1;
  12. }
  13. catch (Exception e)
  14. {
  15. return LuaDLL.toluaL_exception(L, e);
  16. }";
  17. public static string ParseDefined =
  18. @" try
  19. {
  20. int count = LuaDLL.lua_gettop(L);
  21. if (count == 2 && TypeChecker.CheckTypes<System.Type, string>(L, 1))
  22. {
  23. System.Type arg0 = (System.Type)ToLua.ToObject(L, 1);
  24. string arg1 = ToLua.ToString(L, 2);
  25. object o = System.Enum.Parse(arg0, arg1);
  26. ToLua.Push(L, (Enum)o);
  27. return 1;
  28. }
  29. else if (count == 3 && TypeChecker.CheckTypes<System.Type, string, bool>(L, 1))
  30. {
  31. System.Type arg0 = (System.Type)ToLua.ToObject(L, 1);
  32. string arg1 = ToLua.ToString(L, 2);
  33. bool arg2 = LuaDLL.lua_toboolean(L, 3);
  34. object o = System.Enum.Parse(arg0, arg1, arg2);
  35. ToLua.Push(L, (Enum)o);
  36. return 1;
  37. }
  38. else
  39. {
  40. return LuaDLL.luaL_throw(L, ""invalid arguments to method: System.Enum.Parse"");
  41. }
  42. }
  43. catch(Exception e)
  44. {
  45. return LuaDLL.toluaL_exception(L, e);
  46. }";
  47. public static string ToObjectDefined =
  48. @" try
  49. {
  50. int count = LuaDLL.lua_gettop(L);
  51. if (count == 2 && TypeChecker.CheckTypes<System.Type, int>(L, 1))
  52. {
  53. System.Type arg0 = (System.Type)ToLua.ToObject(L, 1);
  54. int arg1 = (int)LuaDLL.lua_tonumber(L, 2);
  55. object o = System.Enum.ToObject(arg0, arg1);
  56. ToLua.Push(L, (Enum)o);
  57. return 1;
  58. }
  59. else if (count == 2 && TypeChecker.CheckTypes<System.Type, object>(L, 1))
  60. {
  61. System.Type arg0 = (System.Type)ToLua.ToObject(L, 1);
  62. object arg1 = ToLua.ToVarObject(L, 2);
  63. object o = System.Enum.ToObject(arg0, arg1);
  64. ToLua.Push(L, (Enum)o);
  65. return 1;
  66. }
  67. else
  68. {
  69. return LuaDLL.luaL_throw(L, ""invalid arguments to method: System.Enum.ToObject"");
  70. }
  71. }
  72. catch(Exception e)
  73. {
  74. return LuaDLL.toluaL_exception(L, e);
  75. }";
  76. [UseDefinedAttribute]
  77. public static void ToInt(System.Enum obj)
  78. {
  79. }
  80. [UseDefinedAttribute]
  81. public static object ToObject(Type enumType, int value)
  82. {
  83. return null;
  84. }
  85. [UseDefinedAttribute]
  86. public static object Parse(Type enumType, string value)
  87. {
  88. return null;
  89. }
  90. }