Skip to content

Commit 1aa964d

Browse files
committed
首次提交
0 parents  commit 1aa964d

File tree

1,078 files changed

+475643
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,078 files changed

+475643
-0
lines changed

.DS_Store

10 KB
Binary file not shown.

.gitignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Object files
2+
*.o
3+
*.ko
4+
*.obj
5+
*.elf
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Libraries
12+
*.lib
13+
*.a
14+
*.la
15+
*.lo
16+
17+
# Shared objects (inc. Windows DLLs)
18+
*.dll
19+
*.so
20+
*.so.*
21+
*.dylib
22+
23+
# Executables
24+
*.exe
25+
*.out
26+
*.app
27+
*.i*86
28+
*.x86_64
29+
*.hex
30+
31+
# Debug files
32+
*.dSYM/

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 topameng
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

Plugins/.DS_Store

6 KB
Binary file not shown.

Plugins/iOS/.DS_Store

6 KB
Binary file not shown.
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>BuildMachineOSBuild</key>
6+
<string>15B42</string>
7+
<key>CFBundleDevelopmentRegion</key>
8+
<string>English</string>
9+
<key>CFBundleExecutable</key>
10+
<string>tolua</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>xlcw.{PRODUCT_NAME:rfc1034identifier}$</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>tolua</string>
17+
<key>CFBundlePackageType</key>
18+
<string>BNDL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleSupportedPlatforms</key>
24+
<array>
25+
<string>MacOSX</string>
26+
</array>
27+
<key>CFBundleVersion</key>
28+
<string>1</string>
29+
<key>CFPlugInDynamicRegisterFunction</key>
30+
<string></string>
31+
<key>CFPlugInDynamicRegistration</key>
32+
<string>NO</string>
33+
<key>CFPlugInFactories</key>
34+
<dict>
35+
<key>00000000-0000-0000-0000-000000000000</key>
36+
<string>MyFactoryFunction</string>
37+
</dict>
38+
<key>CFPlugInTypes</key>
39+
<dict>
40+
<key>00000000-0000-0000-0000-000000000000</key>
41+
<array>
42+
<string>00000000-0000-0000-0000-000000000000</string>
43+
</array>
44+
</dict>
45+
<key>CFPlugInUnloadFunction</key>
46+
<string></string>
47+
<key>DTCompiler</key>
48+
<string>com.apple.compilers.llvm.clang.1_0</string>
49+
<key>DTPlatformBuild</key>
50+
<string>7C68</string>
51+
<key>DTPlatformVersion</key>
52+
<string>GM</string>
53+
<key>DTSDKBuild</key>
54+
<string>15C43</string>
55+
<key>DTSDKName</key>
56+
<string>macosx10.11</string>
57+
<key>DTXcode</key>
58+
<string>0720</string>
59+
<key>DTXcodeBuild</key>
60+
<string>7C68</string>
61+
<key>NSHumanReadableCopyright</key>
62+
<string>Copyright © 2013 xlcw games. All rights reserved.</string>
63+
</dict>
64+
</plist>
1.05 MB
Binary file not shown.

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
NDK: http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86_64.exe
2+
3+
#tolua_runtime
4+
**Build**<br>
5+
pc: build_win32.sh build_win64.h (mingw + luajit2.0.4) <br>
6+
android: build_arm.sh build_x86.sh (mingw + luajit2.0.4) <br>
7+
mac: build_osx.sh (xcode + luac5.1.5 luajit can't run in unity5) <br>
8+
ios: build_ios.sh (xcode + luajit2.1 beta) <br>
9+
10+

android/jni/Android.mk

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
LOCAL_MODULE := libluajit
5+
LOCAL_SRC_FILES := libluajit.a
6+
include $(PREBUILT_STATIC_LIBRARY)
7+
8+
include $(CLEAR_VARS)
9+
LOCAL_FORCE_STATIC_EXECUTABLE := true
10+
LOCAL_MODULE := tolua
11+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../luajit/src
12+
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../pbc
13+
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cjson
14+
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../
15+
16+
LOCAL_CPPFLAGS := -O3
17+
LOCAL_CFLAGS := -O3 -std=gnu99
18+
LOCAL_SRC_FILES := ../../tolua.c \
19+
../../pb.c \
20+
../../lpeg.c \
21+
../../struct.c \
22+
../../sproto/sproto.c \
23+
../../sproto/lsproto.c \
24+
../../pbc/src/alloc.c \
25+
../../pbc/src/array.c \
26+
../../pbc/src/bootstrap.c \
27+
../../pbc/src/context.c \
28+
../../pbc/src/decode.c \
29+
../../pbc/src/map.c \
30+
../../pbc/src/pattern.c \
31+
../../pbc/src/proto.c \
32+
../../pbc/src/register.c \
33+
../../pbc/src/rmessage.c \
34+
../../pbc/src/stringpool.c \
35+
../../pbc/src/varint.c \
36+
../../pbc/src/wmessage.c \
37+
../../pbc/binding/lua/pbc-lua.c \
38+
../../cjson/fpconv.c \
39+
../../cjson/strbuf.c \
40+
../../cjson/lua_cjson.c \
41+
../../luasocket/auxiliar.c \
42+
../../luasocket/buffer.c \
43+
../../luasocket/except.c \
44+
../../luasocket/inet.c \
45+
../../luasocket/io.c \
46+
../../luasocket/luasocket.c \
47+
../../luasocket/luasocket_scripts.c \
48+
../../luasocket/mime.c \
49+
../../luasocket/options.c \
50+
../../luasocket/select.c \
51+
../../luasocket/tcp.c \
52+
../../luasocket/timeout.c \
53+
../../luasocket/udp.c \
54+
../../luasocket/usocket.c \
55+
56+
LOCAL_WHOLE_STATIC_LIBRARIES += libluajit
57+
include $(BUILD_SHARED_LIBRARY)

bit.c

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
** Lua BitOp -- a bit operations library for Lua 5.1/5.2.
3+
** http://bitop.luajit.org/
4+
**
5+
** Copyright (C) 2008-2012 Mike Pall. All rights reserved.
6+
**
7+
** Permission is hereby granted, free of charge, to any person obtaining
8+
** a copy of this software and associated documentation files (the
9+
** "Software"), to deal in the Software without restriction, including
10+
** without limitation the rights to use, copy, modify, merge, publish,
11+
** distribute, sublicense, and/or sell copies of the Software, and to
12+
** permit persons to whom the Software is furnished to do so, subject to
13+
** the following conditions:
14+
**
15+
** The above copyright notice and this permission notice shall be
16+
** included in all copies or substantial portions of the Software.
17+
**
18+
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21+
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23+
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24+
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
**
26+
** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
27+
*/
28+
29+
#define LUA_BITOP_VERSION "1.0.2"
30+
31+
#define LUA_LIB
32+
#include "lua.h"
33+
#include "lauxlib.h"
34+
35+
#ifdef _MSC_VER
36+
/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */
37+
typedef __int32 int32_t;
38+
typedef unsigned __int32 uint32_t;
39+
typedef unsigned __int64 uint64_t;
40+
#else
41+
#include <stdint.h>
42+
#endif
43+
44+
typedef int32_t SBits;
45+
typedef uint32_t UBits;
46+
47+
typedef union {
48+
lua_Number n;
49+
#ifdef LUA_NUMBER_DOUBLE
50+
uint64_t b;
51+
#else
52+
UBits b;
53+
#endif
54+
} BitNum;
55+
56+
/* Convert argument to bit type. */
57+
static UBits barg(lua_State *L, int idx)
58+
{
59+
BitNum bn;
60+
UBits b;
61+
#if LUA_VERSION_NUM < 502
62+
bn.n = lua_tonumber(L, idx);
63+
#else
64+
bn.n = luaL_checknumber(L, idx);
65+
#endif
66+
#if defined(LUA_NUMBER_DOUBLE)
67+
bn.n += 6755399441055744.0; /* 2^52+2^51 */
68+
#ifdef SWAPPED_DOUBLE
69+
b = (UBits)(bn.b >> 32);
70+
#else
71+
b = (UBits)bn.b;
72+
#endif
73+
#elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \
74+
defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
75+
defined(LUA_NUMBER_LLONG)
76+
if (sizeof(UBits) == sizeof(lua_Number))
77+
b = bn.b;
78+
else
79+
b = (UBits)(SBits)bn.n;
80+
#elif defined(LUA_NUMBER_FLOAT)
81+
#error "A 'float' lua_Number type is incompatible with this library"
82+
#else
83+
#error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
84+
#endif
85+
#if LUA_VERSION_NUM < 502
86+
if (b == 0 && !lua_isnumber(L, idx)) {
87+
luaL_typerror(L, idx, "number");
88+
}
89+
#endif
90+
return b;
91+
}
92+
93+
/* Return bit type. */
94+
#define BRET(b) lua_pushnumber(L, (lua_Number)(SBits)(b)); return 1;
95+
96+
static int bit_tobit(lua_State *L) { BRET(barg(L, 1)) }
97+
static int bit_bnot(lua_State *L) { BRET(~barg(L, 1)) }
98+
99+
#define BIT_OP(func, opr) \
100+
static int func(lua_State *L) { int i; UBits b = barg(L, 1); \
101+
for (i = lua_gettop(L); i > 1; i--) b opr barg(L, i); BRET(b) }
102+
BIT_OP(bit_band, &=)
103+
BIT_OP(bit_bor, |=)
104+
BIT_OP(bit_bxor, ^=)
105+
106+
#define bshl(b, n) (b << n)
107+
#define bshr(b, n) (b >> n)
108+
#define bsar(b, n) ((SBits)b >> n)
109+
#define brol(b, n) ((b << n) | (b >> (32-n)))
110+
#define bror(b, n) ((b << (32-n)) | (b >> n))
111+
#define BIT_SH(func, fn) \
112+
static int func(lua_State *L) { \
113+
UBits b = barg(L, 1); UBits n = barg(L, 2) & 31; BRET(fn(b, n)) }
114+
BIT_SH(bit_lshift, bshl)
115+
BIT_SH(bit_rshift, bshr)
116+
BIT_SH(bit_arshift, bsar)
117+
BIT_SH(bit_rol, brol)
118+
BIT_SH(bit_ror, bror)
119+
120+
static int bit_bswap(lua_State *L)
121+
{
122+
UBits b = barg(L, 1);
123+
b = (b >> 24) | ((b >> 8) & 0xff00) | ((b & 0xff00) << 8) | (b << 24);
124+
BRET(b)
125+
}
126+
127+
static int bit_tohex(lua_State *L)
128+
{
129+
UBits b = barg(L, 1);
130+
SBits n = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2);
131+
const char *hexdigits = "0123456789abcdef";
132+
char buf[8];
133+
int i;
134+
if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }
135+
if (n > 8) n = 8;
136+
for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; }
137+
lua_pushlstring(L, buf, (size_t)n);
138+
return 1;
139+
}
140+
141+
static const struct luaL_Reg bit_funcs[] = {
142+
{ "tobit", bit_tobit },
143+
{ "bnot", bit_bnot },
144+
{ "band", bit_band },
145+
{ "bor", bit_bor },
146+
{ "bxor", bit_bxor },
147+
{ "lshift", bit_lshift },
148+
{ "rshift", bit_rshift },
149+
{ "arshift", bit_arshift },
150+
{ "rol", bit_rol },
151+
{ "ror", bit_ror },
152+
{ "bswap", bit_bswap },
153+
{ "tohex", bit_tohex },
154+
{ NULL, NULL }
155+
};
156+
157+
/* Signed right-shifts are implementation-defined per C89/C99.
158+
** But the de facto standard are arithmetic right-shifts on two's
159+
** complement CPUs. This behaviour is required here, so test for it.
160+
*/
161+
#define BAD_SAR (bsar(-8, 2) != (SBits)-2)
162+
163+
LUALIB_API int luaopen_bit(lua_State *L)
164+
{
165+
UBits b;
166+
lua_pushnumber(L, (lua_Number)1437217655L);
167+
b = barg(L, -1);
168+
if (b != (UBits)1437217655L || BAD_SAR) { /* Perform a simple self-test. */
169+
const char *msg = "compiled with incompatible luaconf.h";
170+
#ifdef LUA_NUMBER_DOUBLE
171+
#ifdef _WIN32
172+
if (b == (UBits)1610612736L)
173+
msg = "use D3DCREATE_FPU_PRESERVE with DirectX";
174+
#endif
175+
if (b == (UBits)1127743488L)
176+
msg = "not compiled with SWAPPED_DOUBLE";
177+
#endif
178+
if (BAD_SAR)
179+
msg = "arithmetic right-shift broken";
180+
luaL_error(L, "bit library self-test failed (%s)", msg);
181+
}
182+
#if LUA_VERSION_NUM < 502
183+
luaL_register(L, "bit", bit_funcs);
184+
#else
185+
luaL_newlib(L, bit_funcs);
186+
#endif
187+
return 1;
188+
}
189+

0 commit comments

Comments
 (0)