basic.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. local toWrite = {}
  2. local currentString = ''
  3. local out
  4. local WRITE, OUTPUT = write, output
  5. _is_functions["const PODVector<IntVector2>"] = "not implemented"
  6. _to_functions["const PODVector<IntVector2>"] = "not implemented"
  7. _push_functions["const PODVector<IntVector2>"] = "tolua_pushurho3dconstpodvectorintvector2"
  8. _is_functions["const PODVector<UIElement*>"] = "not implemented"
  9. _to_functions["const PODVector<UIElement*>"] = "not implemented"
  10. _push_functions["const PODVector<UIElement*>"] = "tolua_pushurho3dpodvectoruielement"
  11. _is_functions["const PODVector<unsigned>"] = "tolua_isurho3dconstpodvectorunsigned"
  12. _to_functions["const PODVector<unsigned>"] = "tolua_tourho3dconstpodvectorunsigned"
  13. _push_functions["const PODVector<unsigned>"] = "tolua_pushurho3dconstpodvectorunsigned"
  14. _is_functions["const Vector<String>"] = "tolua_isurho3dconstvectorstring"
  15. _to_functions["const Vector<String>"] = "tolua_tourho3dconstvectorstring"
  16. _push_functions["const Vector<String>"] = "tolua_pushurho3dconstvectorstring"
  17. function output(s)
  18. out = _OUTPUT
  19. output = OUTPUT -- restore
  20. output(s)
  21. end
  22. function write(a)
  23. if out == _OUTPUT then
  24. currentString = currentString .. a
  25. if string.sub(currentString,-1) == '\n' then
  26. toWrite[#toWrite+1] = currentString
  27. currentString = ''
  28. end
  29. else
  30. WRITE(a)
  31. end
  32. end
  33. function post_output_hook(package)
  34. local result = table.concat(toWrite)
  35. local function replace(pattern, replacement)
  36. local k = 0
  37. local nxt, currentString = 1, ''
  38. repeat
  39. local s, e = string.find(result, pattern, nxt, true)
  40. if e then
  41. currentString = currentString .. string.sub(result, nxt, s-1) .. replacement
  42. nxt = e + 1
  43. k = k + 1
  44. end
  45. until not e
  46. result = currentString..string.sub(result, nxt)
  47. --if k == 0 then print('Pattern not replaced', pattern) end
  48. end
  49. replace("\t", " ")
  50. replace([[#ifndef __cplusplus
  51. #include "stdlib.h"
  52. #endif
  53. #include "string.h"
  54. #include "tolua++.h"]], [[//
  55. // Copyright (c) 2008-2013 the Urho3D project.
  56. //
  57. // Permission is hereby granted, free of charge, to any person obtaining a copy
  58. // of this software and associated documentation files (the "Software"), to deal
  59. // in the Software without restriction, including without limitation the rights
  60. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61. // copies of the Software, and to permit persons to whom the Software is
  62. // furnished to do so, subject to the following conditions:
  63. //
  64. // The above copyright notice and this permission notice shall be included in
  65. // all copies or substantial portions of the Software.
  66. //
  67. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  68. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  69. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  70. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  71. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  72. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  73. // THE SOFTWARE.
  74. //
  75. #include "Precompiled.h"
  76. #include "tolua++.h"
  77. #include "tolua++urho3d.h"]]
  78. )
  79. WRITE(result)
  80. end
  81. function get_property_methods_hook(ptype, name)
  82. if ptype == "get_set" then
  83. local Name = string.upper(string.sub(name, 1, 1))..string.sub(name, 2)
  84. return "Get"..Name, "Set"..Name
  85. end
  86. if ptype == "is_set" then
  87. local Name = string.upper(string.sub(name, 1, 1))..string.sub(name, 2)
  88. return "Is"..Name, "Set"..Name
  89. end
  90. if ptype == "has_set" then
  91. local Name = string.upper(string.sub(name, 1, 1))..string.sub(name, 2)
  92. return "Has"..Name, "Set"..Name
  93. end
  94. if ptype == "no_prefix" then
  95. local Name = string.upper(string.sub(name, 1, 1))..string.sub(name, 2)
  96. return Name, "Set"..Name
  97. end
  98. end