*/}}

la_lualibs.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "la_5.h"
  19. extern "C" const char* LA_LUA_LIB_COMMON=R"(
  20. function ddump(tbl, ...)
  21. log("[dump]")
  22. if(type(tbl)~='table') then log("Not a table."); return end
  23. local levels=100
  24. local dtableonly=0
  25. local l,d=...
  26. if(l) then levels=l end
  27. if(d) then dtableonly=d end
  28. local checklist = {}
  29. local function print_kv(indent,k,v,t)
  30. log(indent..t.." "..k,v,""..(t==' ' and type(v) or ""))
  31. end
  32. local function innerdump(tbl,indent,lv)
  33. local tablelist={}; local funclist={}; local otherlist={}
  34. checklist[ tostring(tbl) ] = true
  35. for k,v in pairs(tbl) do
  36. if type(v)=="function" then funclist[k]={v,'f'}
  37. elseif type(v)=="table" then tablelist[k]={v,'t'}
  38. else otherlist[k]={v,' '} end
  39. end
  40. for k,v in pairs(tablelist) do
  41. print_kv(indent,k,v[1],v[2])
  42. if (lv<levels and not checklist[ tostring(v[1]) ]) then innerdump(v[1],indent.." ",lv+1) end
  43. end
  44. if(dtableonly==0) then for k,v in pairs(funclist) do print_kv(indent,k,v[1],v[2]) end end
  45. if(dtableonly==0) then for k,v in pairs(otherlist) do print_kv(indent,k,v[1],v[2]) end end
  46. end
  47. checklist[ tostring(tbl) ] = true
  48. innerdump( tbl, "", 0)
  49. end
  50. function tdump(t)
  51. ddump(t,100,1)
  52. end
  53. ffi = require("ffi")
  54. )";
  55. extern "C" const char* LA_LUA_LIB_AUDIO=R"(
  56. ffi.cdef[[
  57. typedef struct laSynth laSynth;
  58. laSynth* laFindSynth(const char* Name);
  59. void laSynthTriggerNew(laSynth* s);
  60. ]]
  61. )";