basic.lua 4.0 KB

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