candle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +4 -0
- data/VERSION +1 -0
- data/bin/candle +21 -0
- data/lib/candle.rb +68 -0
- data/lib/candle/command.rb +27 -0
- data/lib/candle/generators/actions.rb +183 -0
- data/lib/candle/generators/blank.rb +127 -0
- data/lib/candle/generators/cli.rb +55 -0
- data/lib/candle/generators/help.rb +47 -0
- data/lib/candle/generators/jam.rb +80 -0
- data/lib/candle/generators/lua/scripts/AppDelegate.lua +36 -0
- data/lib/candle/generators/lua/scripts/tests/init.lua +6 -0
- data/lib/candle/generators/lua/scripts/tests/someTest.lua +12 -0
- data/lib/candle/generators/lua/wax/ProtocolLoader.h +12 -0
- data/lib/candle/generators/lua/wax/bin/hammer +157 -0
- data/lib/candle/generators/lua/wax/bin/update-xibs +131 -0
- data/lib/candle/generators/lua/wax/bin/waxsim +0 -0
- data/lib/candle/generators/lua/wax/lib/build-scripts/compile-stdlib.sh +14 -0
- data/lib/candle/generators/lua/wax/lib/build-scripts/copy-scripts.sh +58 -0
- data/lib/candle/generators/lua/wax/lib/build-scripts/luac.lua +80 -0
- data/lib/candle/generators/lua/wax/lib/extensions/CGAffine/wax_CGTransform.h +12 -0
- data/lib/candle/generators/lua/wax/lib/extensions/CGAffine/wax_CGTransform.m +85 -0
- data/lib/candle/generators/lua/wax/lib/extensions/CGContext/wax_CGContext.h +12 -0
- data/lib/candle/generators/lua/wax/lib/extensions/CGContext/wax_CGContext.m +251 -0
- data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http.h +14 -0
- data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http.m +240 -0
- data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http_connection.h +54 -0
- data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http_connection.m +304 -0
- data/lib/candle/generators/lua/wax/lib/extensions/filesystem/wax_filesystem.h +9 -0
- data/lib/candle/generators/lua/wax/lib/extensions/filesystem/wax_filesystem.m +273 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/Rakefile +10 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/wax_json.c +304 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/wax_json.h +11 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl-1.0.9.tar.gz +0 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/api/yajl_common.h +85 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/api/yajl_gen.h +159 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/api/yajl_parse.h +193 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl.c +159 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_alloc.c +65 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_alloc.h +50 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_buf.c +119 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_buf.h +73 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_bytestack.h +85 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_common.h +85 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_encode.c +188 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_encode.h +50 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_gen.c +322 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_gen.h +159 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_lex.c +737 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_lex.h +133 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_parse.h +193 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_parser.c +448 -0
- data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_parser.h +82 -0
- data/lib/candle/generators/lua/wax/lib/lua/lapi.c +1087 -0
- data/lib/candle/generators/lua/wax/lib/lua/lapi.h +16 -0
- data/lib/candle/generators/lua/wax/lib/lua/lauxlib.c +652 -0
- data/lib/candle/generators/lua/wax/lib/lua/lauxlib.h +174 -0
- data/lib/candle/generators/lua/wax/lib/lua/lbaselib.c +653 -0
- data/lib/candle/generators/lua/wax/lib/lua/lcode.c +839 -0
- data/lib/candle/generators/lua/wax/lib/lua/lcode.h +76 -0
- data/lib/candle/generators/lua/wax/lib/lua/ldblib.c +397 -0
- data/lib/candle/generators/lua/wax/lib/lua/ldebug.c +638 -0
- data/lib/candle/generators/lua/wax/lib/lua/ldebug.h +33 -0
- data/lib/candle/generators/lua/wax/lib/lua/ldo.c +518 -0
- data/lib/candle/generators/lua/wax/lib/lua/ldo.h +57 -0
- data/lib/candle/generators/lua/wax/lib/lua/ldump.c +164 -0
- data/lib/candle/generators/lua/wax/lib/lua/lfunc.c +174 -0
- data/lib/candle/generators/lua/wax/lib/lua/lfunc.h +34 -0
- data/lib/candle/generators/lua/wax/lib/lua/lgc.c +711 -0
- data/lib/candle/generators/lua/wax/lib/lua/lgc.h +110 -0
- data/lib/candle/generators/lua/wax/lib/lua/linit.c +38 -0
- data/lib/candle/generators/lua/wax/lib/lua/liolib.c +553 -0
- data/lib/candle/generators/lua/wax/lib/lua/llex.c +461 -0
- data/lib/candle/generators/lua/wax/lib/lua/llex.h +81 -0
- data/lib/candle/generators/lua/wax/lib/lua/llimits.h +128 -0
- data/lib/candle/generators/lua/wax/lib/lua/lmathlib.c +263 -0
- data/lib/candle/generators/lua/wax/lib/lua/lmem.c +86 -0
- data/lib/candle/generators/lua/wax/lib/lua/lmem.h +49 -0
- data/lib/candle/generators/lua/wax/lib/lua/loadlib.c +666 -0
- data/lib/candle/generators/lua/wax/lib/lua/lobject.c +214 -0
- data/lib/candle/generators/lua/wax/lib/lua/lobject.h +381 -0
- data/lib/candle/generators/lua/wax/lib/lua/lopcodes.c +102 -0
- data/lib/candle/generators/lua/wax/lib/lua/lopcodes.h +268 -0
- data/lib/candle/generators/lua/wax/lib/lua/loslib.c +243 -0
- data/lib/candle/generators/lua/wax/lib/lua/lparser.c +1339 -0
- data/lib/candle/generators/lua/wax/lib/lua/lparser.h +82 -0
- data/lib/candle/generators/lua/wax/lib/lua/lstate.c +214 -0
- data/lib/candle/generators/lua/wax/lib/lua/lstate.h +169 -0
- data/lib/candle/generators/lua/wax/lib/lua/lstring.c +111 -0
- data/lib/candle/generators/lua/wax/lib/lua/lstring.h +31 -0
- data/lib/candle/generators/lua/wax/lib/lua/lstrlib.c +869 -0
- data/lib/candle/generators/lua/wax/lib/lua/ltable.c +588 -0
- data/lib/candle/generators/lua/wax/lib/lua/ltable.h +40 -0
- data/lib/candle/generators/lua/wax/lib/lua/ltablib.c +287 -0
- data/lib/candle/generators/lua/wax/lib/lua/ltm.c +75 -0
- data/lib/candle/generators/lua/wax/lib/lua/ltm.h +54 -0
- data/lib/candle/generators/lua/wax/lib/lua/lua.h +388 -0
- data/lib/candle/generators/lua/wax/lib/lua/luaconf.h +753 -0
- data/lib/candle/generators/lua/wax/lib/lua/lualib.h +53 -0
- data/lib/candle/generators/lua/wax/lib/lua/lundump.c +227 -0
- data/lib/candle/generators/lua/wax/lib/lua/lundump.h +36 -0
- data/lib/candle/generators/lua/wax/lib/lua/lvm.c +763 -0
- data/lib/candle/generators/lua/wax/lib/lua/lvm.h +36 -0
- data/lib/candle/generators/lua/wax/lib/lua/lzio.c +82 -0
- data/lib/candle/generators/lua/wax/lib/lua/lzio.h +67 -0
- data/lib/candle/generators/lua/wax/lib/lua/print.c +227 -0
- data/lib/candle/generators/lua/wax/lib/project.rake +159 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/enums.lua +396 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/ext/http.lua +43 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/ext/init.lua +4 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/ext/number.lua +21 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/ext/string.lua +97 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/ext/table.lua +165 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua +49 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/autoload.lua +10 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/base64.lua +64 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/bit.lua +274 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/cache.lua +73 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua +22 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/frame.lua +76 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/init.lua +78 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/pickView.lua +54 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/helpers/time.lua +102 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/init.lua +18 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/luaspec/init.lua +2 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/luaspec/luamock.lua +84 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/luaspec/luaspec.lua +377 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/repl.lua +9 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/structs.lua +11 -0
- data/lib/candle/generators/lua/wax/lib/stdlib/waxClass.lua +42 -0
- data/lib/candle/generators/lua/wax/lib/wax.h +16 -0
- data/lib/candle/generators/lua/wax/lib/wax.m +260 -0
- data/lib/candle/generators/lua/wax/lib/wax_class.h +18 -0
- data/lib/candle/generators/lua/wax/lib/wax_class.m +190 -0
- data/lib/candle/generators/lua/wax/lib/wax_gc.h +20 -0
- data/lib/candle/generators/lua/wax/lib/wax_gc.m +56 -0
- data/lib/candle/generators/lua/wax/lib/wax_helpers.h +102 -0
- data/lib/candle/generators/lua/wax/lib/wax_helpers.m +870 -0
- data/lib/candle/generators/lua/wax/lib/wax_instance.h +34 -0
- data/lib/candle/generators/lua/wax/lib/wax_instance.m +810 -0
- data/lib/candle/generators/lua/wax/lib/wax_server.h +47 -0
- data/lib/candle/generators/lua/wax/lib/wax_server.m +252 -0
- data/lib/candle/generators/lua/wax/lib/wax_stdlib.h +3 -0
- data/lib/candle/generators/lua/wax/lib/wax_struct.h +26 -0
- data/lib/candle/generators/lua/wax/lib/wax_struct.m +335 -0
- data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/project.pbxproj +836 -0
- data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/WaxApplication.xcscheme +86 -0
- data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
- data/lib/candle/generators/templates/blank/WaxApplication/Default-568h@2x.png +0 -0
- data/lib/candle/generators/templates/blank/WaxApplication/Default.png +0 -0
- data/lib/candle/generators/templates/blank/WaxApplication/Default@2x.png +0 -0
- data/lib/candle/generators/templates/blank/WaxApplication/ProtocolLoader.h +12 -0
- data/lib/candle/generators/templates/blank/WaxApplication/WaxApplication-Info.plist.tt +38 -0
- data/lib/candle/generators/templates/blank/WaxApplication/WaxApplication-Prefix.pch.tt +14 -0
- data/lib/candle/generators/templates/blank/WaxApplication/en.lproj/InfoPlist.strings +2 -0
- data/lib/candle/generators/templates/blank/WaxApplication/main.m.tt +20 -0
- data/lib/candle/tasks.rb +22 -0
- data/lib/candle/utility.rb +30 -0
- data/lib/candle/version.rb +9 -0
- data/lib/candle/view.rb +48 -0
- metadata +582 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $
|
3
|
+
** Lua virtual machine
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef lvm_h
|
8
|
+
#define lvm_h
|
9
|
+
|
10
|
+
|
11
|
+
#include "ldo.h"
|
12
|
+
#include "lobject.h"
|
13
|
+
#include "ltm.h"
|
14
|
+
|
15
|
+
|
16
|
+
#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
|
17
|
+
|
18
|
+
#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
|
19
|
+
(((o) = luaV_tonumber(o,n)) != NULL))
|
20
|
+
|
21
|
+
#define equalobj(L,o1,o2) \
|
22
|
+
(ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
|
23
|
+
|
24
|
+
|
25
|
+
LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
|
26
|
+
LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
|
27
|
+
LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
|
28
|
+
LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
|
29
|
+
LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
|
30
|
+
StkId val);
|
31
|
+
LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
|
32
|
+
StkId val);
|
33
|
+
LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
|
34
|
+
LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
|
35
|
+
|
36
|
+
#endif
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $
|
3
|
+
** a generic input stream interface
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#include <string.h>
|
9
|
+
|
10
|
+
#define lzio_c
|
11
|
+
#define LUA_CORE
|
12
|
+
|
13
|
+
#include "lua.h"
|
14
|
+
|
15
|
+
#include "llimits.h"
|
16
|
+
#include "lmem.h"
|
17
|
+
#include "lstate.h"
|
18
|
+
#include "lzio.h"
|
19
|
+
|
20
|
+
|
21
|
+
int luaZ_fill (ZIO *z) {
|
22
|
+
size_t size;
|
23
|
+
lua_State *L = z->L;
|
24
|
+
const char *buff;
|
25
|
+
lua_unlock(L);
|
26
|
+
buff = z->reader(L, z->data, &size);
|
27
|
+
lua_lock(L);
|
28
|
+
if (buff == NULL || size == 0) return EOZ;
|
29
|
+
z->n = size - 1;
|
30
|
+
z->p = buff;
|
31
|
+
return char2int(*(z->p++));
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
int luaZ_lookahead (ZIO *z) {
|
36
|
+
if (z->n == 0) {
|
37
|
+
if (luaZ_fill(z) == EOZ)
|
38
|
+
return EOZ;
|
39
|
+
else {
|
40
|
+
z->n++; /* luaZ_fill removed first byte; put back it */
|
41
|
+
z->p--;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return char2int(*z->p);
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
|
49
|
+
z->L = L;
|
50
|
+
z->reader = reader;
|
51
|
+
z->data = data;
|
52
|
+
z->n = 0;
|
53
|
+
z->p = NULL;
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
/* --------------------------------------------------------------- read --- */
|
58
|
+
size_t luaZ_read (ZIO *z, void *b, size_t n) {
|
59
|
+
while (n) {
|
60
|
+
size_t m;
|
61
|
+
if (luaZ_lookahead(z) == EOZ)
|
62
|
+
return n; /* return number of missing bytes */
|
63
|
+
m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
|
64
|
+
memcpy(b, z->p, m);
|
65
|
+
z->n -= m;
|
66
|
+
z->p += m;
|
67
|
+
b = (char *)b + m;
|
68
|
+
n -= m;
|
69
|
+
}
|
70
|
+
return 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
/* ------------------------------------------------------------------------ */
|
74
|
+
char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
|
75
|
+
if (n > buff->buffsize) {
|
76
|
+
if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
|
77
|
+
luaZ_resizebuffer(L, buff, n);
|
78
|
+
}
|
79
|
+
return buff->buffer;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $
|
3
|
+
** Buffered streams
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef lzio_h
|
9
|
+
#define lzio_h
|
10
|
+
|
11
|
+
#include "lua.h"
|
12
|
+
|
13
|
+
#include "lmem.h"
|
14
|
+
|
15
|
+
|
16
|
+
#define EOZ (-1) /* end of stream */
|
17
|
+
|
18
|
+
typedef struct Zio ZIO;
|
19
|
+
|
20
|
+
#define char2int(c) cast(int, cast(unsigned char, (c)))
|
21
|
+
|
22
|
+
#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z))
|
23
|
+
|
24
|
+
typedef struct Mbuffer {
|
25
|
+
char *buffer;
|
26
|
+
size_t n;
|
27
|
+
size_t buffsize;
|
28
|
+
} Mbuffer;
|
29
|
+
|
30
|
+
#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
|
31
|
+
|
32
|
+
#define luaZ_buffer(buff) ((buff)->buffer)
|
33
|
+
#define luaZ_sizebuffer(buff) ((buff)->buffsize)
|
34
|
+
#define luaZ_bufflen(buff) ((buff)->n)
|
35
|
+
|
36
|
+
#define luaZ_resetbuffer(buff) ((buff)->n = 0)
|
37
|
+
|
38
|
+
|
39
|
+
#define luaZ_resizebuffer(L, buff, size) \
|
40
|
+
(luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \
|
41
|
+
(buff)->buffsize = size)
|
42
|
+
|
43
|
+
#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
|
44
|
+
|
45
|
+
|
46
|
+
LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
|
47
|
+
LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
|
48
|
+
void *data);
|
49
|
+
LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
|
50
|
+
LUAI_FUNC int luaZ_lookahead (ZIO *z);
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
/* --------- Private Part ------------------ */
|
55
|
+
|
56
|
+
struct Zio {
|
57
|
+
size_t n; /* bytes still unread */
|
58
|
+
const char *p; /* current position in buffer */
|
59
|
+
lua_Reader reader;
|
60
|
+
void* data; /* additional data */
|
61
|
+
lua_State *L; /* Lua state (for reader) */
|
62
|
+
};
|
63
|
+
|
64
|
+
|
65
|
+
LUAI_FUNC int luaZ_fill (ZIO *z);
|
66
|
+
|
67
|
+
#endif
|
@@ -0,0 +1,227 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $
|
3
|
+
** print bytecodes
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <ctype.h>
|
8
|
+
#include <stdio.h>
|
9
|
+
|
10
|
+
#define luac_c
|
11
|
+
#define LUA_CORE
|
12
|
+
|
13
|
+
#include "ldebug.h"
|
14
|
+
#include "lobject.h"
|
15
|
+
#include "lopcodes.h"
|
16
|
+
#include "lundump.h"
|
17
|
+
|
18
|
+
#define PrintFunction luaU_print
|
19
|
+
|
20
|
+
#define Sizeof(x) ((int)sizeof(x))
|
21
|
+
#define VOID(p) ((const void*)(p))
|
22
|
+
|
23
|
+
static void PrintString(const TString* ts)
|
24
|
+
{
|
25
|
+
const char* s=getstr(ts);
|
26
|
+
size_t i,n=ts->tsv.len;
|
27
|
+
putchar('"');
|
28
|
+
for (i=0; i<n; i++)
|
29
|
+
{
|
30
|
+
int c=s[i];
|
31
|
+
switch (c)
|
32
|
+
{
|
33
|
+
case '"': printf("\\\""); break;
|
34
|
+
case '\\': printf("\\\\"); break;
|
35
|
+
case '\a': printf("\\a"); break;
|
36
|
+
case '\b': printf("\\b"); break;
|
37
|
+
case '\f': printf("\\f"); break;
|
38
|
+
case '\n': printf("\\n"); break;
|
39
|
+
case '\r': printf("\\r"); break;
|
40
|
+
case '\t': printf("\\t"); break;
|
41
|
+
case '\v': printf("\\v"); break;
|
42
|
+
default: if (isprint((unsigned char)c))
|
43
|
+
putchar(c);
|
44
|
+
else
|
45
|
+
printf("\\%03u",(unsigned char)c);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
putchar('"');
|
49
|
+
}
|
50
|
+
|
51
|
+
static void PrintConstant(const Proto* f, int i)
|
52
|
+
{
|
53
|
+
const TValue* o=&f->k[i];
|
54
|
+
switch (ttype(o))
|
55
|
+
{
|
56
|
+
case LUA_TNIL:
|
57
|
+
printf("nil");
|
58
|
+
break;
|
59
|
+
case LUA_TBOOLEAN:
|
60
|
+
printf(bvalue(o) ? "true" : "false");
|
61
|
+
break;
|
62
|
+
case LUA_TNUMBER:
|
63
|
+
printf(LUA_NUMBER_FMT,nvalue(o));
|
64
|
+
break;
|
65
|
+
case LUA_TSTRING:
|
66
|
+
PrintString(rawtsvalue(o));
|
67
|
+
break;
|
68
|
+
default: /* cannot happen */
|
69
|
+
printf("? type=%d",ttype(o));
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
static void PrintCode(const Proto* f)
|
75
|
+
{
|
76
|
+
const Instruction* code=f->code;
|
77
|
+
int pc,n=f->sizecode;
|
78
|
+
for (pc=0; pc<n; pc++)
|
79
|
+
{
|
80
|
+
Instruction i=code[pc];
|
81
|
+
OpCode o=GET_OPCODE(i);
|
82
|
+
int a=GETARG_A(i);
|
83
|
+
int b=GETARG_B(i);
|
84
|
+
int c=GETARG_C(i);
|
85
|
+
int bx=GETARG_Bx(i);
|
86
|
+
int sbx=GETARG_sBx(i);
|
87
|
+
int line=getline(f,pc);
|
88
|
+
printf("\t%d\t",pc+1);
|
89
|
+
if (line>0) printf("[%d]\t",line); else printf("[-]\t");
|
90
|
+
printf("%-9s\t",luaP_opnames[o]);
|
91
|
+
switch (getOpMode(o))
|
92
|
+
{
|
93
|
+
case iABC:
|
94
|
+
printf("%d",a);
|
95
|
+
if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b);
|
96
|
+
if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c);
|
97
|
+
break;
|
98
|
+
case iABx:
|
99
|
+
if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx);
|
100
|
+
break;
|
101
|
+
case iAsBx:
|
102
|
+
if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx);
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
switch (o)
|
106
|
+
{
|
107
|
+
case OP_LOADK:
|
108
|
+
printf("\t; "); PrintConstant(f,bx);
|
109
|
+
break;
|
110
|
+
case OP_GETUPVAL:
|
111
|
+
case OP_SETUPVAL:
|
112
|
+
printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-");
|
113
|
+
break;
|
114
|
+
case OP_GETGLOBAL:
|
115
|
+
case OP_SETGLOBAL:
|
116
|
+
printf("\t; %s",svalue(&f->k[bx]));
|
117
|
+
break;
|
118
|
+
case OP_GETTABLE:
|
119
|
+
case OP_SELF:
|
120
|
+
if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }
|
121
|
+
break;
|
122
|
+
case OP_SETTABLE:
|
123
|
+
case OP_ADD:
|
124
|
+
case OP_SUB:
|
125
|
+
case OP_MUL:
|
126
|
+
case OP_DIV:
|
127
|
+
case OP_POW:
|
128
|
+
case OP_EQ:
|
129
|
+
case OP_LT:
|
130
|
+
case OP_LE:
|
131
|
+
if (ISK(b) || ISK(c))
|
132
|
+
{
|
133
|
+
printf("\t; ");
|
134
|
+
if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");
|
135
|
+
printf(" ");
|
136
|
+
if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");
|
137
|
+
}
|
138
|
+
break;
|
139
|
+
case OP_JMP:
|
140
|
+
case OP_FORLOOP:
|
141
|
+
case OP_FORPREP:
|
142
|
+
printf("\t; to %d",sbx+pc+2);
|
143
|
+
break;
|
144
|
+
case OP_CLOSURE:
|
145
|
+
printf("\t; %p",VOID(f->p[bx]));
|
146
|
+
break;
|
147
|
+
case OP_SETLIST:
|
148
|
+
if (c==0) printf("\t; %d",(int)code[++pc]);
|
149
|
+
else printf("\t; %d",c);
|
150
|
+
break;
|
151
|
+
default:
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
printf("\n");
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
#define SS(x) (x==1)?"":"s"
|
159
|
+
#define S(x) x,SS(x)
|
160
|
+
|
161
|
+
static void PrintHeader(const Proto* f)
|
162
|
+
{
|
163
|
+
const char* s=getstr(f->source);
|
164
|
+
if (*s=='@' || *s=='=')
|
165
|
+
s++;
|
166
|
+
else if (*s==LUA_SIGNATURE[0])
|
167
|
+
s="(bstring)";
|
168
|
+
else
|
169
|
+
s="(string)";
|
170
|
+
printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n",
|
171
|
+
(f->linedefined==0)?"main":"function",s,
|
172
|
+
f->linedefined,f->lastlinedefined,
|
173
|
+
S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f));
|
174
|
+
printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
|
175
|
+
f->numparams,f->is_vararg?"+":"",SS(f->numparams),
|
176
|
+
S(f->maxstacksize),S(f->nups));
|
177
|
+
printf("%d local%s, %d constant%s, %d function%s\n",
|
178
|
+
S(f->sizelocvars),S(f->sizek),S(f->sizep));
|
179
|
+
}
|
180
|
+
|
181
|
+
static void PrintConstants(const Proto* f)
|
182
|
+
{
|
183
|
+
int i,n=f->sizek;
|
184
|
+
printf("constants (%d) for %p:\n",n,VOID(f));
|
185
|
+
for (i=0; i<n; i++)
|
186
|
+
{
|
187
|
+
printf("\t%d\t",i+1);
|
188
|
+
PrintConstant(f,i);
|
189
|
+
printf("\n");
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
static void PrintLocals(const Proto* f)
|
194
|
+
{
|
195
|
+
int i,n=f->sizelocvars;
|
196
|
+
printf("locals (%d) for %p:\n",n,VOID(f));
|
197
|
+
for (i=0; i<n; i++)
|
198
|
+
{
|
199
|
+
printf("\t%d\t%s\t%d\t%d\n",
|
200
|
+
i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
static void PrintUpvalues(const Proto* f)
|
205
|
+
{
|
206
|
+
int i,n=f->sizeupvalues;
|
207
|
+
printf("upvalues (%d) for %p:\n",n,VOID(f));
|
208
|
+
if (f->upvalues==NULL) return;
|
209
|
+
for (i=0; i<n; i++)
|
210
|
+
{
|
211
|
+
printf("\t%d\t%s\n",i,getstr(f->upvalues[i]));
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
void PrintFunction(const Proto* f, int full)
|
216
|
+
{
|
217
|
+
int i,n=f->sizep;
|
218
|
+
PrintHeader(f);
|
219
|
+
PrintCode(f);
|
220
|
+
if (full)
|
221
|
+
{
|
222
|
+
PrintConstants(f);
|
223
|
+
PrintLocals(f);
|
224
|
+
PrintUpvalues(f);
|
225
|
+
}
|
226
|
+
for (i=0; i<n; i++) PrintFunction(f->p[i],full);
|
227
|
+
}
|
@@ -0,0 +1,159 @@
|
|
1
|
+
TEXTMATE_FILE="TEXTMATE"
|
2
|
+
WAX_PATH = File.expand_path("wax")
|
3
|
+
WAX_PATH = File.expand_path("wax.framework/Resources") if not File.exists?(WAX_PATH)
|
4
|
+
|
5
|
+
desc "Create a Wax TextMate project"
|
6
|
+
task :tm => "TEXTMATE" do
|
7
|
+
sh "mate #{TEXTMATE_FILE} ./scripts ./wax/lib/stdlib"
|
8
|
+
sh "mate #{TEXTMATE_FILE}"
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :tm do
|
12
|
+
desc "Install textmate lua & wax bundles"
|
13
|
+
task :install_bundles do
|
14
|
+
sh "mkdir -p ~/Library/Application\\ Support/TextMate/Bundles/"
|
15
|
+
|
16
|
+
lua_bundle_dir = "~/Library/Application\\ Support/TextMate/Bundles/Lua.tmbundle"
|
17
|
+
if not sh("test -e #{lua_bundle_dir}") {|ok, status| ok} # This is bad code...
|
18
|
+
sh "curl -L http://github.com/textmate/lua.tmbundle/tarball/master | tar xvz"
|
19
|
+
sh "mv textmate-lua.tmbundle* #{lua_bundle_dir}"
|
20
|
+
end
|
21
|
+
|
22
|
+
wax_bundle_dir = "~/Library/Application\\ Support/TextMate/Bundles/Wax.tmbundle"
|
23
|
+
if not sh("test -e #{wax_bundle_dir}") {|ok, status| ok}
|
24
|
+
sh "curl -L http://github.com/probablycorey/Wax.tmbundle/tarball/master | tar xvz"
|
25
|
+
sh "mv probablycorey-[Ww]ax.tmbundle* #{wax_bundle_dir}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
file TEXTMATE_FILE do |t|
|
30
|
+
open(t.name, "w") do |file|
|
31
|
+
file.write <<-TEXTMATE_HELP
|
32
|
+
Some tips to make life easier
|
33
|
+
|
34
|
+
1) Install the Lua and Wax TextMate Bundles.
|
35
|
+
a) Either type "rake tm:install_bundles"
|
36
|
+
|
37
|
+
Or, you can manually install the bundles from
|
38
|
+
http://github.com/textmate/lua.tmbundle and
|
39
|
+
http://github.com/probablycorey/Wax.tmbundle
|
40
|
+
into ~/Library/Application\ Support/TextMate/Bundles
|
41
|
+
|
42
|
+
b) From TextMate click Bundles > Bundle Editor > Reload Bundles
|
43
|
+
|
44
|
+
TEXTMATE_HELP
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Update the wax lib with the lastest code"
|
50
|
+
task :update do
|
51
|
+
puts
|
52
|
+
puts "User Input Required!"
|
53
|
+
puts "--------------------"
|
54
|
+
print "About to remove wax directory '#{WAX_PATH}' and replace it with an updated version (y/n) "
|
55
|
+
|
56
|
+
if STDIN.gets !~ /^y/i
|
57
|
+
puts "Exiting... nothing was done!"
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
tmp_dir = "./_wax-download"
|
62
|
+
rm_rf tmp_dir
|
63
|
+
mkdir_p tmp_dir
|
64
|
+
sh "curl -L http://github.com/probablycorey/wax/tarball/master | tar -C #{tmp_dir} -x -z"
|
65
|
+
rm_rf WAX_PATH
|
66
|
+
sh "mv #{tmp_dir}/* \"#{WAX_PATH}\""
|
67
|
+
rm_rf tmp_dir
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Git specific tasks"
|
71
|
+
namespace :git do
|
72
|
+
|
73
|
+
desc "make the wax folder a submodule"
|
74
|
+
task :sub do
|
75
|
+
rm_rf WAX_PATH
|
76
|
+
sh "git init"
|
77
|
+
sh "git submodule add git@github.com:probablycorey/wax.git wax"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Build and run tests on the app"
|
82
|
+
task :test do
|
83
|
+
sh "#{WAX_PATH}/bin/hammer --headless WAX_TEST=YES"
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Runs a REPL on the current app"
|
87
|
+
task :console do
|
88
|
+
sh "#{WAX_PATH}/bin/hammer --headless WAX_REPL=YES"
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Build"
|
92
|
+
task :build do
|
93
|
+
sh "#{WAX_PATH}/bin/hammer"
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Package an adhoc build"
|
97
|
+
task :adhoc do
|
98
|
+
#sh "#{WAX_PATH}/bin/hammer clean"
|
99
|
+
#rm_rf "build"
|
100
|
+
|
101
|
+
output = `#{WAX_PATH}/bin/hammer -c 'Ad\\ Hoc' -v`
|
102
|
+
success = ($? == 0)
|
103
|
+
if not success
|
104
|
+
puts output
|
105
|
+
else
|
106
|
+
puts output
|
107
|
+
provisioning_id = output[/PROVISIONING_PROFILE\s+([\w\-]+)/, 1]
|
108
|
+
provisioning_profile = `grep -rl '#{provisioning_id}' '#{ENV['HOME']}/Library/MobileDevice/Provisioning\ Profiles/'`.split("\n").first.strip
|
109
|
+
puts provisioning_id
|
110
|
+
|
111
|
+
raise "Could not find the Ad Hoc provisioning profile matching #{provisioning_id}" if not provisioning_profile or not provisioning_id
|
112
|
+
|
113
|
+
app_file = output[/CODESIGNING_FOLDER_PATH\s+(.*?)$/, 1]
|
114
|
+
executable_name = output[/EXECUTABLE_NAME\s+(.*?)$/, 1]
|
115
|
+
output_dir = "archive"
|
116
|
+
rm_rf output_dir
|
117
|
+
mkdir output_dir
|
118
|
+
|
119
|
+
sh "zip -r #{output_dir}/#{executable_name}.ipa '#{provisioning_profile}' #{app_file}"
|
120
|
+
sh "open #{output_dir}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
desc "Package a distribution build"
|
125
|
+
task :distribution do
|
126
|
+
if not ENV["sdk"]
|
127
|
+
raise "\nYou need to specify an sdk!\nUsage: rake adhoc sdk=iphoneos3.0\n"
|
128
|
+
end
|
129
|
+
|
130
|
+
sh "#{WAX_PATH}/bin/hammer clean"
|
131
|
+
rm_rf "build"
|
132
|
+
|
133
|
+
output = `#{WAX_PATH}/bin/hammer --sdk #{ENV["sdk"]} -c 'Distribution' -v`
|
134
|
+
success = ($? == 0)
|
135
|
+
if not success
|
136
|
+
puts output
|
137
|
+
else
|
138
|
+
timestamp = Time.now.strftime("%m-%d-%y")
|
139
|
+
dir = "distribution-builds/#{timestamp}"
|
140
|
+
rm_rf dir
|
141
|
+
mkdir_p dir
|
142
|
+
|
143
|
+
app_file = Dir["build/Distribution-iphoneos/*.app"]
|
144
|
+
|
145
|
+
sh "mv '#{app_file}' '#{dir}'"
|
146
|
+
sh "cd '#{dir}'; zip -r distribution.zip ./*"
|
147
|
+
sh "open #{dir}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
desc "Build and run the app"
|
152
|
+
task :run do
|
153
|
+
sh "#{WAX_PATH}/bin/hammer --run"
|
154
|
+
end
|
155
|
+
|
156
|
+
desc "Goes through your lua scripts and updates all the xibs to know about waxClasses"
|
157
|
+
task :ib do
|
158
|
+
sh "#{WAX_PATH}/bin/update-xibs"
|
159
|
+
end
|