Skip to content

Commit 5ce3e50

Browse files
author
brinkqiang
committed
FIRST_RESERVED
1 parent 2d3bb29 commit 5ce3e50

File tree

181 files changed

+100755
-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.

181 files changed

+100755
-0
lines changed

CMakeLists.txt

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
PROJECT(dmlua)
4+
5+
IF(UNIX)
6+
ADD_DEFINITIONS(-DLUA_USE_LINUX)
7+
ADD_DEFINITIONS(-DLUA_COMPAT_MODULE)
8+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/)
9+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
10+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua)
11+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/lua)
12+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/tolua)
13+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/test)
14+
LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/lin)
15+
16+
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
17+
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/lin)
18+
19+
#FILE(GLOB_RECURSE DMLUA_SOURCES
20+
#${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/*.hpp
21+
#${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/*.h)
22+
23+
#ADD_LIBRARY(dmlua ${DMLUA_SOURCES})
24+
25+
FILE(GLOB_RECURSE TOLUA_SOURCES
26+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.cpp
27+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.cc
28+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.c
29+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.hpp
30+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.h
31+
32+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.cpp
33+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.cc
34+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.c
35+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.hpp
36+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.h)
37+
38+
ADD_LIBRARY(tolua ${TOLUA_SOURCES})
39+
40+
FILE(GLOB_RECURSE TOLUA++_SOURCES
41+
${CMAKE_CURRENT_SOURCE_DIR}/tool/tolua.c
42+
${CMAKE_CURRENT_SOURCE_DIR}/tool/toluabind.c
43+
${CMAKE_CURRENT_SOURCE_DIR}/tool/*.hpp
44+
${CMAKE_CURRENT_SOURCE_DIR}/tool/*.h)
45+
46+
ADD_EXECUTABLE(tolua++ ${TOLUA++_SOURCES})
47+
TARGET_LINK_LIBRARIES(tolua++ tolua m dl pthread)
48+
49+
FILE(GLOB_RECURSE TEST_SOURCES
50+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp
51+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.cc
52+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.c
53+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.hpp
54+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.h
55+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.pkg
56+
${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/dmlua.h)
57+
58+
ADD_EXECUTABLE(dmluatest ${TEST_SOURCES})
59+
TARGET_LINK_LIBRARIES(dmluatest tolua m dl pthread)
60+
61+
ADD_CUSTOM_COMMAND(PRE_BUILD
62+
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/test/script/dmlua
63+
COMMAND tolua++ -t -n interface -o interface.cpp -H interface.h package.pkg
64+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua
65+
DEPENDS tolua++
66+
)
67+
ELSEIF(WIN32)
68+
ADD_DEFINITIONS(-DLUA_COMPAT_MODULE)
69+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/)
70+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
71+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua)
72+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/lua)
73+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/tolua)
74+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/test)
75+
76+
LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/win)
77+
78+
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
79+
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/win)
80+
81+
#FILE(GLOB_RECURSE DMLUA_SOURCES
82+
#${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/*.hpp
83+
#${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/*.h)
84+
85+
#ADD_LIBRARY(dmlua ${DMLUA_SOURCES})
86+
87+
FILE(GLOB_RECURSE TOLUA_SOURCES
88+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.cpp
89+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.cc
90+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.c
91+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.hpp
92+
${CMAKE_CURRENT_SOURCE_DIR}/src/lua/*.h
93+
94+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.cpp
95+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.cc
96+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.c
97+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.hpp
98+
${CMAKE_CURRENT_SOURCE_DIR}/src/tolua/*.h
99+
100+
${CMAKE_CURRENT_SOURCE_DIR}/include/tolua.h)
101+
102+
ADD_LIBRARY(tolua ${TOLUA_SOURCES})
103+
104+
FILE(GLOB_RECURSE TOLUA++_SOURCES
105+
${CMAKE_CURRENT_SOURCE_DIR}/tool/tolua.c
106+
${CMAKE_CURRENT_SOURCE_DIR}/tool/toluabind.c
107+
${CMAKE_CURRENT_SOURCE_DIR}/tool/*.hpp
108+
${CMAKE_CURRENT_SOURCE_DIR}/tool/*.h
109+
110+
${CMAKE_CURRENT_SOURCE_DIR}/include/tolua.h)
111+
112+
ADD_EXECUTABLE(tolua++ ${TOLUA++_SOURCES})
113+
TARGET_LINK_LIBRARIES(tolua++ tolua)
114+
115+
FILE(GLOB_RECURSE TEST_SOURCES
116+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp
117+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.cc
118+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.c
119+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.hpp
120+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.h
121+
${CMAKE_CURRENT_SOURCE_DIR}/test/*.pkg
122+
${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/*.h
123+
${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua/dmlua.h)
124+
125+
ADD_EXECUTABLE(dmluatest ${TEST_SOURCES})
126+
TARGET_LINK_LIBRARIES(dmluatest tolua)
127+
128+
ADD_CUSTOM_COMMAND(PRE_BUILD
129+
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/test/script/dmlua
130+
COMMAND tolua++ -t -n interface -o interface.cpp -H interface.h package.pkg
131+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/dmlua
132+
DEPENDS tolua++
133+
)
134+
ENDIF(UNIX)

bin/script/common/math.lua

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- lua script
2+
module (..., package.seeall)
3+
4+
function add(a, b, res)
5+
res.value = a + b
6+
end

bin/script/common/test.lua

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- lua script
2+
module (..., package.seeall)
3+
4+
function main(vec)
5+
6+
vec:push_back('world')
7+
8+
print(vec:size())
9+
10+
for i=0,vec:size()-1,1 do print(vec[i]) end
11+
12+
end

bin/script/config/loadcsv.lua

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module (..., package.seeall)
2+
3+
function dump (t)
4+
print(t)
5+
for k,v in pairs(t) do
6+
print(k,v, type(v))
7+
end
8+
end
9+
10+
function main()
11+
local w = csv.writer('test.csv')
12+
w:write {'Name is \"that\"','Product','Date','Age'}
13+
14+
w:write {'steve', 'bonzo \"dog\" catcher','10/10/09',3}
15+
w:write {'bonzo','dog,cat','23/04/08',10}
16+
w:write {'john','CowCatcher','20/10/09',4}
17+
w:close()
18+
19+
local r,c = csv.reader('test.csv',true,true)
20+
if c then
21+
print 'headers'
22+
dump(c)
23+
end
24+
25+
--[[
26+
row = r:read()
27+
while row do
28+
dump(row)
29+
row = r:read()
30+
end
31+
--]]
32+
33+
for row in r:rows() do
34+
dump(row) -- can use row:copy() to get unique tables
35+
end
36+
end
37+

bin/script/task/task.lua

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- lua script
2+
module (..., package.seeall)
3+
4+
function AcceptTask(role, taskid, ret)
5+
print("==================================")
6+
print("Player Name = " .. role:GetName())
7+
print("AcceptTask taskid = " .. taskid)
8+
9+
if role:AcceptTask(taskid) then
10+
ret.value = 0
11+
print("AcceptTask ret = " .. ret.value)
12+
13+
else
14+
ret.value = -1
15+
print("AcceptTask ret = " .. ret.value)
16+
end
17+
18+
print("###################################")
19+
end
20+
21+
function FinishTask(role, taskid)
22+
print("==================================")
23+
print("Player Name = " .. role:GetName())
24+
print("FinishTask taskid = " .. taskid)
25+
print("==================================")
26+
role:FinishTask(taskid)
27+
end

bin/script/task/timer.lua

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- lua script
2+
module (..., package.seeall)
3+
4+
function main(role, taskid)
5+
print(role:GetName() .. " & " .. taskid)
6+
role:AcceptTask(taskid)
7+
end
8+
9+
function main1(t1)
10+
11+
end
12+
13+
function main2(t1, t2)
14+
15+
end
16+
17+
function main3(t1, t2, t3)
18+
19+
end
20+
21+
function main4(t1, t2, t3, t4)
22+
23+
end
24+
25+
function main5(t1, t2, t3, t4, t5)
26+
27+
end

bin/script/task/unit.lua

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
-- lua script
2+
module (..., package.seeall)
3+
4+
function main()
5+
print("==================================")
6+
print("==================================")
7+
end
8+
9+
function main1(t1)
10+
print("==================================")
11+
print("in unit t1 = " .. t1)
12+
print("==================================")
13+
end
14+
15+
function main2(t1, t2)
16+
print("==================================")
17+
print("in unit t1 = " .. t1)
18+
print("in unit t2 = " .. t2)
19+
print("==================================")
20+
end
21+
22+
function main3(t1, t2, t3)
23+
print("==================================")
24+
print("in unit t1 = " .. t1)
25+
print("in unit t2 = " .. t2)
26+
print("in unit t3 = " .. t3)
27+
print("==================================")
28+
end
29+
30+
function main4(t1, t2, t3, t4)
31+
print("==================================")
32+
print("in unit t1 = " .. t1)
33+
print("in unit t2 = " .. t2)
34+
print("in unit t3 = " .. t3)
35+
print("in unit t4 = " .. t4)
36+
print("==================================")
37+
end
38+
39+
function main5(t1, t2, t3, t4, t5)
40+
print("==================================")
41+
print("in unit t1 = " .. t1)
42+
print("in unit t2 = " .. t2)
43+
print("in unit t3 = " .. t3)
44+
print("in unit t4 = " .. t4)
45+
print("in unit t5 = " .. t5)
46+
print("==================================")
47+
end

build4nmake.bat

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rem need run vcvarsall.bat
2+
rmdir /S /Q nmake_build
3+
mkdir nmake_build
4+
cd nmake_build
5+
cmake -G "NMake Makefiles" ..
6+
nmake -f makefile
7+
cd ..

build4unix.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rm -rf unix_build
2+
mkdir unix_build
3+
cd unix_build
4+
cmake -DCMAKE_BUILD_TYPE=relwithdebinfo ..
5+
make
6+
cd ..

build4unix_debug.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rm -rf unix_build_debug
2+
mkdir unix_build_debug
3+
cd unix_build_debug
4+
cmake -DCMAKE_BUILD_TYPE=debug ..
5+
make
6+
cd ..

0 commit comments

Comments
 (0)