sweet-moon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +40 -0
  5. data/Gemfile +12 -0
  6. data/Gemfile.lock +61 -0
  7. data/README.md +1149 -0
  8. data/components/api.rb +83 -0
  9. data/components/injections/injections_503.rb +21 -0
  10. data/components/injections/injections_514.rb +29 -0
  11. data/components/injections/injections_542.rb +49 -0
  12. data/components/injections.rb +11 -0
  13. data/components/interpreters/50/function.rb +52 -0
  14. data/components/interpreters/50/interpreter.rb +105 -0
  15. data/components/interpreters/50/reader.rb +65 -0
  16. data/components/interpreters/50/table.rb +99 -0
  17. data/components/interpreters/50/writer.rb +45 -0
  18. data/components/interpreters/51/function.rb +52 -0
  19. data/components/interpreters/51/interpreter.rb +104 -0
  20. data/components/interpreters/51/reader.rb +65 -0
  21. data/components/interpreters/51/table.rb +60 -0
  22. data/components/interpreters/51/writer.rb +45 -0
  23. data/components/interpreters/54/function.rb +52 -0
  24. data/components/interpreters/54/interpreter.rb +100 -0
  25. data/components/interpreters/54/reader.rb +65 -0
  26. data/components/interpreters/54/table.rb +60 -0
  27. data/components/interpreters/54/writer.rb +45 -0
  28. data/components/interpreters.rb +11 -0
  29. data/components/io.rb +11 -0
  30. data/config/tests.sample.yml +15 -0
  31. data/controllers/api.rb +143 -0
  32. data/controllers/cli/cli.rb +32 -0
  33. data/controllers/cli/help.rb +24 -0
  34. data/controllers/cli/signatures.rb +179 -0
  35. data/controllers/cli/version.rb +14 -0
  36. data/controllers/interpreter.rb +68 -0
  37. data/controllers/state.rb +74 -0
  38. data/dsl/api.rb +31 -0
  39. data/dsl/cache.rb +118 -0
  40. data/dsl/concerns/fennel.rb +13 -0
  41. data/dsl/concerns/packages.rb +37 -0
  42. data/dsl/errors.rb +28 -0
  43. data/dsl/fennel.rb +47 -0
  44. data/dsl/global.rb +42 -0
  45. data/dsl/state.rb +104 -0
  46. data/dsl/sweet_moon.rb +53 -0
  47. data/logic/api.rb +17 -0
  48. data/logic/interpreter.rb +84 -0
  49. data/logic/interpreters/interpreter_50.rb +34 -0
  50. data/logic/interpreters/interpreter_51.rb +37 -0
  51. data/logic/interpreters/interpreter_54.rb +41 -0
  52. data/logic/io.rb +6 -0
  53. data/logic/options.rb +14 -0
  54. data/logic/shared_object.rb +52 -0
  55. data/logic/signature.rb +258 -0
  56. data/logic/signatures/ffi_types.rb +27 -0
  57. data/logic/signatures/signatures_322.rb +418 -0
  58. data/logic/signatures/signatures_401.rb +243 -0
  59. data/logic/signatures/signatures_503.rb +575 -0
  60. data/logic/signatures/signatures_514.rb +460 -0
  61. data/logic/signatures/signatures_542.rb +591 -0
  62. data/logic/spec.rb +13 -0
  63. data/logic/tables.rb +32 -0
  64. data/ports/in/dsl/sweet-moon/errors.rb +3 -0
  65. data/ports/in/dsl/sweet-moon.rb +1 -0
  66. data/ports/in/shell/sweet-moon +5 -0
  67. data/ports/in/shell.rb +21 -0
  68. data/ports/out/shell.rb +9 -0
  69. data/sweet-moon.gemspec +35 -0
  70. metadata +137 -0
@@ -0,0 +1,591 @@
1
+ module Logic
2
+ module V542
3
+ Signatures = {
4
+ functions: [{ source: 'LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);',
5
+ ffi: [:luaL_buffinitsize, %i[pointer pointer ulong], :pointer] },
6
+ { source: 'LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);',
7
+ ffi: [:luaL_prepbuffsize, %i[pointer ulong], :pointer] },
8
+ { source: 'LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, size_t *l);',
9
+ ffi: [:luaL_checklstring, %i[pointer int pointer], :pointer] },
10
+ { source: 'LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, const char *r);',
11
+ ffi: [:luaL_gsub, %i[pointer pointer pointer pointer], :pointer] },
12
+ { source: 'LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, const char *def, size_t *l);',
13
+ ffi: [:luaL_optlstring, %i[pointer int pointer pointer], :pointer] },
14
+ { source: 'LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);',
15
+ ffi: [:luaL_tolstring, %i[pointer int pointer], :pointer] },
16
+ { source: 'LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);',
17
+ ffi: [:luaL_argerror, %i[pointer int pointer], :int] },
18
+ { source: 'LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);',
19
+ ffi: [:luaL_callmeta, %i[pointer int pointer], :int] },
20
+ { source: 'LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, const char *const lst[]);',
21
+ ffi: [:luaL_checkoption, %i[pointer int pointer pointer], :int] },
22
+ { source: 'LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);',
23
+ ffi: [:luaL_error, %i[pointer pointer varargs], :int] },
24
+ { source: 'LUALIB_API int (luaL_execresult) (lua_State *L, int stat);',
25
+ ffi: [:luaL_execresult, %i[pointer int], :int] },
26
+ { source: 'LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);',
27
+ ffi: [:luaL_fileresult, %i[pointer int pointer], :int] },
28
+ { source: 'LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);',
29
+ ffi: [:luaL_getmetafield, %i[pointer int pointer], :int] },
30
+ { source: 'LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);',
31
+ ffi: [:luaL_getsubtable, %i[pointer int pointer], :int] },
32
+ { source: 'LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);',
33
+ ffi: [:luaL_loadbufferx,
34
+ %i[pointer pointer ulong pointer pointer],
35
+ :int] },
36
+ { source: 'LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, const char *mode);',
37
+ ffi: [:luaL_loadfilex, %i[pointer pointer pointer], :int] },
38
+ { source: 'LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);',
39
+ ffi: [:luaL_loadstring, %i[pointer pointer], :int] },
40
+ { source: 'LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);',
41
+ ffi: [:luaL_newmetatable, %i[pointer pointer], :int] },
42
+ { source: 'LUALIB_API int (luaL_ref) (lua_State *L, int t);',
43
+ ffi: [:luaL_ref, %i[pointer int], :int] },
44
+ { source: 'LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);',
45
+ ffi: [:luaL_typeerror, %i[pointer int pointer], :int] },
46
+ { source: 'LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);',
47
+ ffi: [:luaL_checkinteger, %i[pointer int], :int] },
48
+ { source: 'LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);',
49
+ ffi: [:luaL_len, %i[pointer int], :int] },
50
+ { source: 'LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, lua_Integer def);',
51
+ ffi: [:luaL_optinteger, %i[pointer int int], :int] },
52
+ { source: 'LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);',
53
+ ffi: [:luaL_checknumber, %i[pointer int], :double] },
54
+ { source: 'LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);',
55
+ ffi: [:luaL_optnumber, %i[pointer int double], :double] },
56
+ { source: 'LUALIB_API lua_State *(luaL_newstate) (void);',
57
+ ffi: [:luaL_newstate, [], :pointer] },
58
+ { source: 'LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);',
59
+ ffi: [:luaL_addlstring, %i[pointer pointer ulong], :void] },
60
+ { source: 'LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);',
61
+ ffi: [:luaL_addstring, %i[pointer pointer], :void] },
62
+ { source: 'LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);',
63
+ ffi: [:luaL_addvalue, [:pointer], :void] },
64
+ { source: 'LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);',
65
+ ffi: [:luaL_buffinit, %i[pointer pointer], :void] },
66
+ { source: 'LUALIB_API void (luaL_checkany) (lua_State *L, int arg);',
67
+ ffi: [:luaL_checkany, %i[pointer int], :void] },
68
+ { source: 'LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);',
69
+ ffi: [:luaL_checkstack, %i[pointer int pointer], :void] },
70
+ { source: 'LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);',
71
+ ffi: [:luaL_checktype, %i[pointer int int], :void] },
72
+ { source: 'LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);',
73
+ ffi: [:luaL_checkversion_, %i[pointer double ulong], :void] },
74
+ { source: 'LUALIB_API void (luaL_openlibs) (lua_State *L);',
75
+ ffi: [:luaL_openlibs, [:pointer], :void] },
76
+ { source: 'LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);',
77
+ ffi: [:luaL_pushresult, [:pointer], :void] },
78
+ { source: 'LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);',
79
+ ffi: [:luaL_pushresultsize, %i[pointer ulong], :void] },
80
+ { source: 'LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, lua_CFunction openf, int glb);',
81
+ ffi: [:luaL_requiref, %i[pointer pointer int int], :void] },
82
+ { source: 'LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);',
83
+ ffi: [:luaL_setfuncs, %i[pointer pointer int], :void] },
84
+ { source: 'LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);',
85
+ ffi: [:luaL_setmetatable, %i[pointer pointer], :void] },
86
+ { source: 'LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, const char *msg, int level);',
87
+ ffi: [:luaL_traceback, %i[pointer pointer pointer int], :void] },
88
+ { source: 'LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);',
89
+ ffi: [:luaL_unref, %i[pointer int int], :void] },
90
+ { source: 'LUALIB_API void (luaL_where) (lua_State *L, int lvl);',
91
+ ffi: [:luaL_where, %i[pointer int], :void] },
92
+ { source: 'LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);',
93
+ ffi: [:luaL_checkudata, %i[pointer int pointer], :pointer] },
94
+ { source: 'LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);',
95
+ ffi: [:luaL_testudata, %i[pointer int pointer], :pointer] },
96
+ { source: 'LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, const char *p, const char *r);',
97
+ ffi: [:luaL_addgsub, %i[pointer pointer pointer pointer], :void] },
98
+ { source: 'LUAMOD_API int (luaopen_base) (lua_State *L);',
99
+ ffi: [:luaopen_base, [:pointer], :int] },
100
+ { source: 'LUAMOD_API int (luaopen_coroutine) (lua_State *L);',
101
+ ffi: [:luaopen_coroutine, [:pointer], :int] },
102
+ { source: 'LUAMOD_API int (luaopen_debug) (lua_State *L);',
103
+ ffi: [:luaopen_debug, [:pointer], :int] },
104
+ { source: 'LUAMOD_API int (luaopen_io) (lua_State *L);',
105
+ ffi: [:luaopen_io, [:pointer], :int] },
106
+ { source: 'LUAMOD_API int (luaopen_math) (lua_State *L);',
107
+ ffi: [:luaopen_math, [:pointer], :int] },
108
+ { source: 'LUAMOD_API int (luaopen_os) (lua_State *L);',
109
+ ffi: [:luaopen_os, [:pointer], :int] },
110
+ { source: 'LUAMOD_API int (luaopen_package) (lua_State *L);',
111
+ ffi: [:luaopen_package, [:pointer], :int] },
112
+ { source: 'LUAMOD_API int (luaopen_string) (lua_State *L);',
113
+ ffi: [:luaopen_string, [:pointer], :int] },
114
+ { source: 'LUAMOD_API int (luaopen_table) (lua_State *L);',
115
+ ffi: [:luaopen_table, [:pointer], :int] },
116
+ { source: 'LUAMOD_API int (luaopen_utf8) (lua_State *L);',
117
+ ffi: [:luaopen_utf8, [:pointer], :int] },
118
+ { source: 'LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);',
119
+ ffi: [:lua_getlocal, %i[pointer pointer int], :pointer] },
120
+ { source: 'LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);',
121
+ ffi: [:lua_getupvalue, %i[pointer int int], :pointer] },
122
+ { source: 'LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);',
123
+ ffi: [:lua_pushfstring, %i[pointer pointer varargs], :pointer] },
124
+ { source: 'LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);',
125
+ ffi: [:lua_pushlstring, %i[pointer pointer ulong], :pointer] },
126
+ { source: 'LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);',
127
+ ffi: [:lua_pushstring, %i[pointer pointer], :pointer] },
128
+ { source: 'LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, va_list argp);',
129
+ ffi: [:lua_pushvfstring, %i[pointer pointer varargs], :pointer] },
130
+ { source: 'LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);',
131
+ ffi: [:lua_setlocal, %i[pointer pointer int], :pointer] },
132
+ { source: 'LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);',
133
+ ffi: [:lua_setupvalue, %i[pointer int int], :pointer] },
134
+ { source: 'LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);',
135
+ ffi: [:lua_tolstring, %i[pointer int pointer], :pointer] },
136
+ { source: 'LUA_API const char *(lua_typename) (lua_State *L, int tp);',
137
+ ffi: [:lua_typename, %i[pointer int], :pointer] },
138
+ { source: 'LUA_API const void *(lua_topointer) (lua_State *L, int idx);',
139
+ ffi: [:lua_topointer, %i[pointer int], :pointer] },
140
+ { source: 'LUA_API int (lua_absindex) (lua_State *L, int idx);',
141
+ ffi: [:lua_absindex, %i[pointer int], :int] },
142
+ { source: 'LUA_API int (lua_checkstack) (lua_State *L, int n);',
143
+ ffi: [:lua_checkstack, %i[pointer int], :int] },
144
+ { source: 'LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);',
145
+ ffi: [:lua_compare, %i[pointer int int int], :int] },
146
+ { source: 'LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip);',
147
+ ffi: [:lua_dump, %i[pointer int pointer int], :int] },
148
+ { source: 'LUA_API int (lua_error) (lua_State *L);',
149
+ ffi: [:lua_error, [:pointer], :int] },
150
+ { source: 'LUA_API int (lua_gc) (lua_State *L, int what, ...);',
151
+ ffi: [:lua_gc, %i[pointer int varargs], :int] },
152
+ { source: 'LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k);',
153
+ ffi: [:lua_getfield, %i[pointer int pointer], :int] },
154
+ { source: 'LUA_API int (lua_getglobal) (lua_State *L, const char *name);',
155
+ ffi: [:lua_getglobal, %i[pointer pointer], :int] },
156
+ { source: 'LUA_API int (lua_gethookcount) (lua_State *L);',
157
+ ffi: [:lua_gethookcount, [:pointer], :int] },
158
+ { source: 'LUA_API int (lua_gethookmask) (lua_State *L);',
159
+ ffi: [:lua_gethookmask, [:pointer], :int] },
160
+ { source: 'LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n);',
161
+ ffi: [:lua_geti, %i[pointer int int], :int] },
162
+ { source: 'LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);',
163
+ ffi: [:lua_getinfo, %i[pointer pointer pointer], :int] },
164
+ { source: 'LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n);',
165
+ ffi: [:lua_getiuservalue, %i[pointer int int], :int] },
166
+ { source: 'LUA_API int (lua_getmetatable) (lua_State *L, int objindex);',
167
+ ffi: [:lua_getmetatable, %i[pointer int], :int] },
168
+ { source: 'LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);',
169
+ ffi: [:lua_getstack, %i[pointer int pointer], :int] },
170
+ { source: 'LUA_API int (lua_gettable) (lua_State *L, int idx);',
171
+ ffi: [:lua_gettable, %i[pointer int], :int] },
172
+ { source: 'LUA_API int (lua_gettop) (lua_State *L);',
173
+ ffi: [:lua_gettop, [:pointer], :int] },
174
+ { source: 'LUA_API int (lua_iscfunction) (lua_State *L, int idx);',
175
+ ffi: [:lua_iscfunction, %i[pointer int], :int] },
176
+ { source: 'LUA_API int (lua_isinteger) (lua_State *L, int idx);',
177
+ ffi: [:lua_isinteger, %i[pointer int], :int] },
178
+ { source: 'LUA_API int (lua_isnumber) (lua_State *L, int idx);',
179
+ ffi: [:lua_isnumber, %i[pointer int], :int] },
180
+ { source: 'LUA_API int (lua_isstring) (lua_State *L, int idx);',
181
+ ffi: [:lua_isstring, %i[pointer int], :int] },
182
+ { source: 'LUA_API int (lua_isuserdata) (lua_State *L, int idx);',
183
+ ffi: [:lua_isuserdata, %i[pointer int], :int] },
184
+ { source: 'LUA_API int (lua_isyieldable) (lua_State *L);',
185
+ ffi: [:lua_isyieldable, [:pointer], :int] },
186
+ { source: 'LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode);',
187
+ ffi: [:lua_load, %i[pointer char pointer pointer pointer], :int] },
188
+ { source: 'LUA_API int (lua_next) (lua_State *L, int idx);',
189
+ ffi: [:lua_next, %i[pointer int], :int] },
190
+ { source: 'LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k);',
191
+ ffi: [:lua_pcallk, %i[pointer int int int int int], :int] },
192
+ { source: 'LUA_API int (lua_pushthread) (lua_State *L);',
193
+ ffi: [:lua_pushthread, [:pointer], :int] },
194
+ { source: 'LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);',
195
+ ffi: [:lua_rawequal, %i[pointer int int], :int] },
196
+ { source: 'LUA_API int (lua_rawget) (lua_State *L, int idx);',
197
+ ffi: [:lua_rawget, %i[pointer int], :int] },
198
+ { source: 'LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n);',
199
+ ffi: [:lua_rawgeti, %i[pointer int int], :int] },
200
+ { source: 'LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p);',
201
+ ffi: [:lua_rawgetp, %i[pointer int pointer], :int] },
202
+ { source: 'LUA_API int (lua_resetthread) (lua_State *L);',
203
+ ffi: [:lua_resetthread, [:pointer], :int] },
204
+ { source: 'LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg, int *nres);',
205
+ ffi: [:lua_resume, %i[pointer pointer int pointer], :int] },
206
+ { source: 'LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit);',
207
+ ffi: [:lua_setcstacklimit, %i[pointer int], :int] },
208
+ { source: 'LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n);',
209
+ ffi: [:lua_setiuservalue, %i[pointer int int], :int] },
210
+ { source: 'LUA_API int (lua_setmetatable) (lua_State *L, int objindex);',
211
+ ffi: [:lua_setmetatable, %i[pointer int], :int] },
212
+ { source: 'LUA_API int (lua_status) (lua_State *L);',
213
+ ffi: [:lua_status, [:pointer], :int] },
214
+ { source: 'LUA_API int (lua_toboolean) (lua_State *L, int idx);',
215
+ ffi: [:lua_toboolean, %i[pointer int], :int] },
216
+ { source: 'LUA_API int (lua_type) (lua_State *L, int idx);',
217
+ ffi: [:lua_type, %i[pointer int], :int] },
218
+ { source: 'LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k);',
219
+ ffi: [:lua_yieldk, %i[pointer int int int], :int] },
220
+ { source: 'LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);',
221
+ ffi: [:lua_getallocf, %i[pointer pointer], :void] },
222
+ { source: 'LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);',
223
+ ffi: [:lua_atpanic, %i[pointer int], :int] },
224
+ { source: 'LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);',
225
+ ffi: [:lua_tocfunction, %i[pointer int], :int] },
226
+ { source: 'LUA_API lua_Hook (lua_gethook) (lua_State *L);',
227
+ ffi: [:lua_gethook, [:pointer], :void] },
228
+ { source: 'LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum);',
229
+ ffi: [:lua_tointegerx, %i[pointer int pointer], :int] },
230
+ { source: 'LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum);',
231
+ ffi: [:lua_tonumberx, %i[pointer int pointer], :double] },
232
+ { source: 'LUA_API lua_Number (lua_version) (lua_State *L);',
233
+ ffi: [:lua_version, [:pointer], :double] },
234
+ { source: 'LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);',
235
+ ffi: [:lua_newstate, %i[void pointer], :pointer] },
236
+ { source: 'LUA_API lua_State *(lua_newthread) (lua_State *L);',
237
+ ffi: [:lua_newthread, [:pointer], :pointer] },
238
+ { source: 'LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);',
239
+ ffi: [:lua_tothread, %i[pointer int], :pointer] },
240
+ { source: 'LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx);',
241
+ ffi: [:lua_rawlen, %i[pointer int], :uint] },
242
+ { source: 'LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);',
243
+ ffi: [:lua_stringtonumber, %i[pointer pointer], :ulong] },
244
+ { source: 'LUA_API void (lua_arith) (lua_State *L, int op);',
245
+ ffi: [:lua_arith, %i[pointer int], :void] },
246
+ { source: 'LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k);',
247
+ ffi: [:lua_callk, %i[pointer int int int int], :void] },
248
+ { source: 'LUA_API void (lua_close) (lua_State *L);',
249
+ ffi: [:lua_close, [:pointer], :void] },
250
+ { source: 'LUA_API void (lua_concat) (lua_State *L, int n);',
251
+ ffi: [:lua_concat, %i[pointer int], :void] },
252
+ { source: 'LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx);',
253
+ ffi: [:lua_copy, %i[pointer int int], :void] },
254
+ { source: 'LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);',
255
+ ffi: [:lua_createtable, %i[pointer int int], :void] },
256
+ { source: 'LUA_API void (lua_len) (lua_State *L, int idx);',
257
+ ffi: [:lua_len, %i[pointer int], :void] },
258
+ { source: 'LUA_API void (lua_pushboolean) (lua_State *L, int b);',
259
+ ffi: [:lua_pushboolean, %i[pointer int], :void] },
260
+ { source: 'LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);',
261
+ ffi: [:lua_pushcclosure, %i[pointer int int], :void] },
262
+ { source: 'LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);',
263
+ ffi: [:lua_pushinteger, %i[pointer int], :void] },
264
+ { source: 'LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);',
265
+ ffi: [:lua_pushlightuserdata, %i[pointer pointer], :void] },
266
+ { source: 'LUA_API void (lua_pushnil) (lua_State *L);',
267
+ ffi: [:lua_pushnil, [:pointer], :void] },
268
+ { source: 'LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);',
269
+ ffi: [:lua_pushnumber, %i[pointer double], :void] },
270
+ { source: 'LUA_API void (lua_pushvalue) (lua_State *L, int idx);',
271
+ ffi: [:lua_pushvalue, %i[pointer int], :void] },
272
+ { source: 'LUA_API void (lua_rawset) (lua_State *L, int idx);',
273
+ ffi: [:lua_rawset, %i[pointer int], :void] },
274
+ { source: 'LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n);',
275
+ ffi: [:lua_rawseti, %i[pointer int int], :void] },
276
+ { source: 'LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p);',
277
+ ffi: [:lua_rawsetp, %i[pointer int pointer], :void] },
278
+ { source: 'LUA_API void (lua_rotate) (lua_State *L, int idx, int n);',
279
+ ffi: [:lua_rotate, %i[pointer int int], :void] },
280
+ { source: 'LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);',
281
+ ffi: [:lua_setallocf, %i[pointer void pointer], :void] },
282
+ { source: 'LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);',
283
+ ffi: [:lua_setfield, %i[pointer int pointer], :void] },
284
+ { source: 'LUA_API void (lua_setglobal) (lua_State *L, const char *name);',
285
+ ffi: [:lua_setglobal, %i[pointer pointer], :void] },
286
+ { source: 'LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);',
287
+ ffi: [:lua_sethook, %i[pointer void int int], :void] },
288
+ { source: 'LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n);',
289
+ ffi: [:lua_seti, %i[pointer int int], :void] },
290
+ { source: 'LUA_API void (lua_settable) (lua_State *L, int idx);',
291
+ ffi: [:lua_settable, %i[pointer int], :void] },
292
+ { source: 'LUA_API void (lua_settop) (lua_State *L, int idx);',
293
+ ffi: [:lua_settop, %i[pointer int], :void] },
294
+ { source: 'LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud);',
295
+ ffi: [:lua_setwarnf, %i[pointer void pointer], :void] },
296
+ { source: 'LUA_API void (lua_toclose) (lua_State *L, int idx);',
297
+ ffi: [:lua_toclose, %i[pointer int], :void] },
298
+ { source: 'LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, int fidx2, int n2);',
299
+ ffi: [:lua_upvaluejoin, %i[pointer int int int int], :void] },
300
+ { source: 'LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont);',
301
+ ffi: [:lua_warning, %i[pointer pointer int], :void] },
302
+ { source: 'LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);',
303
+ ffi: [:lua_xmove, %i[pointer pointer int], :void] },
304
+ { source: 'LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue);',
305
+ ffi: [:lua_newuserdatauv, %i[pointer ulong int], :pointer] },
306
+ { source: 'LUA_API void *(lua_touserdata) (lua_State *L, int idx);',
307
+ ffi: [:lua_touserdata, %i[pointer int], :pointer] },
308
+ { source: 'LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);',
309
+ ffi: [:lua_upvalueid, %i[pointer int int], :pointer] }],
310
+ macros: [{ source: '#define luaC_barrier(L,p,v) ( \\ (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \\ luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0))',
311
+ name: 'luaC_barrier',
312
+ input: %w[L p v] },
313
+ { source: '#define luaC_barrierback(L,p,v) ( \\ (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \\ luaC_barrierback_(L,p) : cast_void(0))',
314
+ name: 'luaC_barrierback',
315
+ input: %w[L p v] },
316
+ { source: '#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0)',
317
+ name: 'luaC_checkGC',
318
+ input: ['L'] },
319
+ { source: '#define luaC_objbarrier(L,p,o) ( \\ (isblack(p) && iswhite(o)) ? \\ luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))',
320
+ name: 'luaC_objbarrier',
321
+ input: %w[L p o] },
322
+ { source: '#define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS)',
323
+ name: 'luaC_white',
324
+ input: ['g'] },
325
+ { source: '#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)',
326
+ name: 'luaD_checkstack',
327
+ input: %w[L n] },
328
+ { source: '#define luaK_codeABC(fs,o,a,b,c) luaK_codeABCk(fs,o,a,b,c,0)',
329
+ name: 'luaK_codeABC',
330
+ input: %w[fs o a b c] },
331
+ { source: '#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t)',
332
+ name: 'luaK_jumpto',
333
+ input: %w[fs t] },
334
+ { source: '#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET)',
335
+ name: 'luaK_setmultret',
336
+ input: %w[fs e] },
337
+ { source: '#define luaL_addsize(B,s) ((B)->n += (s))',
338
+ name: 'luaL_addsize',
339
+ input: %w[B s] },
340
+ { source: '#define luaL_buffsub(B,s) ((B)->n -= (s))',
341
+ name: 'luaL_buffsub',
342
+ input: %w[B s] },
343
+ { source: '#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))',
344
+ name: 'luaL_checkint',
345
+ input: %w[L n] },
346
+ { source: '#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))',
347
+ name: 'luaL_checklong',
348
+ input: %w[L n] },
349
+ { source: '#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))',
350
+ name: 'luaL_checkstring',
351
+ input: %w[L n] },
352
+ { source: '#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))',
353
+ name: 'luaL_checkunsigned',
354
+ input: %w[L a] },
355
+ { source: '#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))',
356
+ name: 'luaL_getmetatable',
357
+ input: %w[L n] },
358
+ { source: '#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)',
359
+ name: 'luaL_loadbuffer',
360
+ input: %w[L s sz n] },
361
+ { source: '#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)',
362
+ name: 'luaL_loadfile',
363
+ input: %w[L f] },
364
+ { source: '#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))',
365
+ name: 'luaL_opt',
366
+ input: %w[L f n d] },
367
+ { source: '#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))',
368
+ name: 'luaL_optint',
369
+ input: %w[L n d] },
370
+ { source: '#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))',
371
+ name: 'luaL_optlong',
372
+ input: %w[L n d] },
373
+ { source: '#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))',
374
+ name: 'luaL_optstring',
375
+ input: %w[L n d] },
376
+ { source: '#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)',
377
+ name: 'luaL_prepbuffer',
378
+ input: ['B'] },
379
+ { source: '#define luaL_pushfail(L) lua_pushnil(L)',
380
+ name: 'luaL_pushfail',
381
+ input: ['L'] },
382
+ { source: '#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))',
383
+ name: 'luaL_typename',
384
+ input: %w[L i] },
385
+ { source: '#define luaM_error(L) luaD_throw(L, LUA_ERRMEM)',
386
+ name: 'luaM_error',
387
+ input: ['L'] },
388
+ { source: '#define luaM_free(L, b) luaM_free_(L, (b), sizeof(*(b)))',
389
+ name: 'luaM_free',
390
+ input: %w[L b] },
391
+ { source: '#define luaM_freearray(L, b, n) luaM_free_(L, (b), (n)*sizeof(*(b)))',
392
+ name: 'luaM_freearray',
393
+ input: %w[L b n] },
394
+ { source: '#define luaM_freemem(L, b, s) luaM_free_(L, (b), (s))',
395
+ name: 'luaM_freemem',
396
+ input: %w[L b s] },
397
+ { source: '#define luaM_new(L,t) cast(t*, luaM_malloc_(L, sizeof(t), 0))',
398
+ name: 'luaM_new',
399
+ input: %w[L t] },
400
+ { source: '#define luaM_newobject(L,tag,s) luaM_malloc_(L, (s), tag)',
401
+ name: 'luaM_newobject',
402
+ input: %w[L tag s] },
403
+ { source: '#define luaM_newvector(L,n,t) cast(t*, luaM_malloc_(L, (n)*sizeof(t), 0))',
404
+ name: 'luaM_newvector',
405
+ input: %w[L n t] },
406
+ { source: '#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \\ (sizeof(s)/sizeof(char))-1))',
407
+ name: 'luaS_newliteral',
408
+ input: %w[L s] },
409
+ { source: '#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)',
410
+ name: 'luaV_rawequalobj',
411
+ input: %w[t1 t2] },
412
+ { source: '#define luaZ_buffremove(buff,i) ((buff)->n -= (i))',
413
+ name: 'luaZ_buffremove',
414
+ input: %w[buff i] },
415
+ { source: '#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)',
416
+ name: 'luaZ_freebuffer',
417
+ input: %w[L buff] },
418
+ { source: '#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)',
419
+ name: 'luaZ_initbuffer',
420
+ input: %w[L buff] },
421
+ { source: '#define lua_assert(c) assert(c)',
422
+ name: 'lua_assert',
423
+ input: ['c'] },
424
+ { source: '#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)',
425
+ name: 'lua_call',
426
+ input: %w[L n r] },
427
+ { source: '#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)',
428
+ name: 'lua_equal',
429
+ input: %w[L idx1 idx2] },
430
+ { source: '#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE))',
431
+ name: 'lua_getextraspaceL',
432
+ input: ['void'] },
433
+ { source: '#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])',
434
+ name: 'lua_getlocaledecpoint',
435
+ input: [] },
436
+ { source: '#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1)',
437
+ name: 'lua_getuservalue',
438
+ input: %w[L idx] },
439
+ { source: '#define lua_insert(L,idx) lua_rotate(L, (idx), 1)',
440
+ name: 'lua_insert',
441
+ input: %w[L idx] },
442
+ { source: '#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)',
443
+ name: 'lua_isboolean',
444
+ input: %w[L n] },
445
+ { source: '#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)',
446
+ name: 'lua_isfunction',
447
+ input: %w[L n] },
448
+ { source: '#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)',
449
+ name: 'lua_islightuserdata',
450
+ input: %w[L n] },
451
+ { source: '#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)',
452
+ name: 'lua_isnil',
453
+ input: %w[L n] },
454
+ { source: '#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)',
455
+ name: 'lua_isnone',
456
+ input: %w[L n] },
457
+ { source: '#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)',
458
+ name: 'lua_isnoneornil',
459
+ input: %w[L n] },
460
+ { source: '#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)',
461
+ name: 'lua_istable',
462
+ input: %w[L n] },
463
+ { source: '#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)',
464
+ name: 'lua_isthread',
465
+ input: %w[L n] },
466
+ { source: '#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)',
467
+ name: 'lua_lessthan',
468
+ input: %w[L idx1 idx2] },
469
+ { source: '#define lua_newtable(L) lua_createtable(L, 0, 0)',
470
+ name: 'lua_newtable',
471
+ input: ['L'] },
472
+ { source: '#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1)',
473
+ name: 'lua_newuserdata',
474
+ input: %w[L s] },
475
+ { source: '#define lua_objlen(L,i) lua_rawlen(L, (i))',
476
+ name: 'lua_objlen',
477
+ input: %w[L i] },
478
+ { source: '#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)',
479
+ name: 'lua_pcall',
480
+ input: %w[L n r f] },
481
+ { source: '#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p)',
482
+ name: 'lua_pointer2str',
483
+ input: %w[buff sz p] },
484
+ { source: '#define lua_pop(L,n) lua_settop(L, -(n)-1)',
485
+ name: 'lua_pop',
486
+ input: %w[L n] },
487
+ { source: '#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)',
488
+ name: 'lua_pushcfunction',
489
+ input: %w[L f] },
490
+ { source: '#define lua_pushliteral(L, s) lua_pushstring(L, "" s)',
491
+ name: 'lua_pushliteral',
492
+ input: %w[L s] },
493
+ { source: '#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))',
494
+ name: 'lua_pushunsigned',
495
+ input: %w[L n] },
496
+ { source: '#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))',
497
+ name: 'lua_register',
498
+ input: %w[L n f] },
499
+ { source: '#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))',
500
+ name: 'lua_remove',
501
+ input: %w[L idx] },
502
+ { source: '#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))',
503
+ name: 'lua_replace',
504
+ input: %w[L idx] },
505
+ { source: '#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1)',
506
+ name: 'lua_setuservalue',
507
+ input: %w[L idx] },
508
+ { source: '#define lua_str2number(s,p) strtold((s), (p))',
509
+ name: 'lua_str2number',
510
+ input: %w[s p] },
511
+ { source: '#define lua_strlen(L,i) lua_rawlen(L, (i))',
512
+ name: 'lua_strlen',
513
+ input: %w[L i] },
514
+ { source: '#define lua_strx2number(s,p) lua_str2number(s,p)',
515
+ name: 'lua_strx2number',
516
+ input: %w[s p] },
517
+ { source: '#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL)',
518
+ name: 'lua_tointeger',
519
+ input: %w[L i] },
520
+ { source: '#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL)',
521
+ name: 'lua_tonumber',
522
+ input: %w[L i] },
523
+ { source: '#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)',
524
+ name: 'lua_tostring',
525
+ input: %w[L i] },
526
+ { source: '#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL)',
527
+ name: 'lua_tounsigned',
528
+ input: %w[L i] },
529
+ { source: '#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is))',
530
+ name: 'lua_tounsignedx',
531
+ input: %w[L i is] },
532
+ { source: '#define lua_writeline() (lua_writestring("\\n", 1), fflush(stdout))',
533
+ name: 'lua_writeline',
534
+ input: [] },
535
+ { source: '#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)',
536
+ name: 'lua_writestring',
537
+ input: %w[s l] },
538
+ { source: '#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)',
539
+ name: 'lua_yield',
540
+ input: %w[L n] },
541
+ { source: '#define luai_apicheck(l,e) assert(e)',
542
+ name: 'luai_apicheck',
543
+ input: %w[l e] },
544
+ { source: '#define luai_numadd(L,a,b) ((a)+(b))',
545
+ name: 'luai_numadd',
546
+ input: %w[L a b] },
547
+ { source: '#define luai_numdiv(L,a,b) ((a)/(b))',
548
+ name: 'luai_numdiv',
549
+ input: %w[L a b] },
550
+ { source: '#define luai_numeq(a,b) ((a)==(b))',
551
+ name: 'luai_numeq',
552
+ input: %w[a b] },
553
+ { source: '#define luai_numge(a,b) ((a)>=(b))',
554
+ name: 'luai_numge',
555
+ input: %w[a b] },
556
+ { source: '#define luai_numgt(a,b) ((a)>(b))',
557
+ name: 'luai_numgt',
558
+ input: %w[a b] },
559
+ { source: '#define luai_numidiv(L,a,b) ((void)L, l_floor(luai_numdiv(L,a,b)))',
560
+ name: 'luai_numidiv',
561
+ input: %w[L a b] },
562
+ { source: '#define luai_numle(a,b) ((a)<=(b))',
563
+ name: 'luai_numle',
564
+ input: %w[a b] },
565
+ { source: '#define luai_numlt(a,b) ((a)<(b))',
566
+ name: 'luai_numlt',
567
+ input: %w[a b] },
568
+ { source: '#define luai_nummul(L,a,b) ((a)*(b))',
569
+ name: 'luai_nummul',
570
+ input: %w[L a b] },
571
+ { source: '#define luai_numsub(L,a,b) ((a)-(b))',
572
+ name: 'luai_numsub',
573
+ input: %w[L a b] },
574
+ { source: '#define luai_numunm(L,a) (-(a))',
575
+ name: 'luai_numunm',
576
+ input: %w[L a] },
577
+ { source: '#define luai_userstatefree(L,L1) ((void)L)',
578
+ name: 'luai_userstatefree',
579
+ input: %w[L L1] },
580
+ { source: '#define luai_userstateresume(L,n) ((void)L)',
581
+ name: 'luai_userstateresume',
582
+ input: %w[L n] },
583
+ { source: '#define luai_userstatethread(L,L1) ((void)L)',
584
+ name: 'luai_userstatethread',
585
+ input: %w[L L1] },
586
+ { source: '#define luai_userstateyield(L,n) ((void)L)',
587
+ name: 'luai_userstateyield',
588
+ input: %w[L n] }]
589
+ }
590
+ end
591
+ end
data/logic/spec.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Logic
2
+ Spec = {
3
+ name: 'sweet-moon',
4
+ command: 'sweet-moon',
5
+ version: '0.0.1',
6
+ author: 'gbaptista',
7
+ summary: 'Lua / Fennel from Ruby and vice versa.',
8
+ description: 'A resilient solution that makes working with Lua / Fennel from ' \
9
+ 'Ruby and vice versa a delightful experience.',
10
+ github: 'https://github.com/gbaptista/sweet-moon',
11
+ license: 'MIT'
12
+ }
13
+ end
data/logic/tables.rb ADDED
@@ -0,0 +1,32 @@
1
+ module Logic
2
+ Tables = {
3
+ to_hash_or_array: ->(tuples) {
4
+ indexes = tuples.map { |kv| kv[0] }
5
+
6
+ is_array = true
7
+
8
+ previous = 0.0
9
+
10
+ indexes.each do |index|
11
+ is_array = false unless index.is_a? Numeric
12
+ is_array = false if index != previous + 1
13
+
14
+ break unless is_array
15
+
16
+ previous += 1
17
+ end
18
+
19
+ # TODO: How to handle empty?
20
+ return tuples.map { |kv| kv[1] } if indexes.size.positive? && is_array
21
+
22
+ result = {}
23
+
24
+ tuples.each do |key_value|
25
+ key, value = key_value
26
+ result[key] = value
27
+ end
28
+
29
+ result
30
+ }
31
+ }
32
+ end
@@ -0,0 +1,3 @@
1
+ require_relative '../../../../dsl/errors'
2
+
3
+ include SweetMoon::Errors
@@ -0,0 +1 @@
1
+ require_relative '../../../dsl/sweet_moon'