Classloader.lua.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. local typeof = typeof
  2. local isInstanceOfType = typeof(CS.System.Type).IsInstanceOfType
  3. local function isFromCSharp(T)
  4. if T then
  5. return T.__name ~= nil or T.UnderlyingSystemType ~= nil
  6. end
  7. return false
  8. end
  9. local function isUserdataType(obj, T)
  10. if isFromCSharp(T) then
  11. return isInstanceOfType(typeof(T), obj)
  12. end
  13. return false
  14. end
  15. local config = {
  16. customTypeCheck = function (T)
  17. if isFromCSharp(T) then
  18. return isUserdataType
  19. end
  20. end,
  21. customTypeof = function (T)
  22. if isFromCSharp(T) then
  23. return typeof(T)
  24. end
  25. return nil
  26. end,
  27. }
  28. if jit then
  29. -- luajit table.move may causes a crash in a version, do not confirm whether the current version is fixed
  30. table.move = function(a1, f, e, t, a2)
  31. if a2 == nil then a2 = a1 end
  32. if t > f then
  33. t = e - f + t
  34. while e >= f do
  35. a2[t] = a1[e]
  36. t = t - 1
  37. e = e - 1
  38. end
  39. else
  40. while f <= e do
  41. a2[t] = a1[f]
  42. t = t + 1
  43. f = f + 1
  44. end
  45. end
  46. end
  47. end
  48. require("CSharpLua.All")("CSharpLua", config)