Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
81a48a9e
提交
81a48a9e
authored
11月 13, 2013
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
missed a few files in new lua commit
上级
27714987
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
522 行增加
和
0 行删除
+522
-0
lbitlib.c
src/mod/languages/mod_lua/lua/lbitlib.c
+211
-0
lcorolib.c
src/mod/languages/mod_lua/lua/lcorolib.c
+155
-0
lctype.c
src/mod/languages/mod_lua/lua/lctype.c
+52
-0
lctype.h
src/mod/languages/mod_lua/lua/lctype.h
+95
-0
lua.hpp
src/mod/languages/mod_lua/lua/lua.hpp
+9
-0
没有找到文件。
src/mod/languages/mod_lua/lua/lbitlib.c
0 → 100644
浏览文件 @
81a48a9e
/*
** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp $
** Standard library for bitwise operations
** See Copyright Notice in lua.h
*/
#define lbitlib_c
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
/* number of bits to consider in a number */
#if !defined(LUA_NBITS)
#define LUA_NBITS 32
#endif
#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1))
/* macro to trim extra bits */
#define trim(x) ((x) & ALLONES)
/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */
#define mask(n) (~((ALLONES << 1) << ((n) - 1)))
typedef
lua_Unsigned
b_uint
;
static
b_uint
andaux
(
lua_State
*
L
)
{
int
i
,
n
=
lua_gettop
(
L
);
b_uint
r
=
~
(
b_uint
)
0
;
for
(
i
=
1
;
i
<=
n
;
i
++
)
r
&=
luaL_checkunsigned
(
L
,
i
);
return
trim
(
r
);
}
static
int
b_and
(
lua_State
*
L
)
{
b_uint
r
=
andaux
(
L
);
lua_pushunsigned
(
L
,
r
);
return
1
;
}
static
int
b_test
(
lua_State
*
L
)
{
b_uint
r
=
andaux
(
L
);
lua_pushboolean
(
L
,
r
!=
0
);
return
1
;
}
static
int
b_or
(
lua_State
*
L
)
{
int
i
,
n
=
lua_gettop
(
L
);
b_uint
r
=
0
;
for
(
i
=
1
;
i
<=
n
;
i
++
)
r
|=
luaL_checkunsigned
(
L
,
i
);
lua_pushunsigned
(
L
,
trim
(
r
));
return
1
;
}
static
int
b_xor
(
lua_State
*
L
)
{
int
i
,
n
=
lua_gettop
(
L
);
b_uint
r
=
0
;
for
(
i
=
1
;
i
<=
n
;
i
++
)
r
^=
luaL_checkunsigned
(
L
,
i
);
lua_pushunsigned
(
L
,
trim
(
r
));
return
1
;
}
static
int
b_not
(
lua_State
*
L
)
{
b_uint
r
=
~
luaL_checkunsigned
(
L
,
1
);
lua_pushunsigned
(
L
,
trim
(
r
));
return
1
;
}
static
int
b_shift
(
lua_State
*
L
,
b_uint
r
,
int
i
)
{
if
(
i
<
0
)
{
/* shift right? */
i
=
-
i
;
r
=
trim
(
r
);
if
(
i
>=
LUA_NBITS
)
r
=
0
;
else
r
>>=
i
;
}
else
{
/* shift left */
if
(
i
>=
LUA_NBITS
)
r
=
0
;
else
r
<<=
i
;
r
=
trim
(
r
);
}
lua_pushunsigned
(
L
,
r
);
return
1
;
}
static
int
b_lshift
(
lua_State
*
L
)
{
return
b_shift
(
L
,
luaL_checkunsigned
(
L
,
1
),
luaL_checkint
(
L
,
2
));
}
static
int
b_rshift
(
lua_State
*
L
)
{
return
b_shift
(
L
,
luaL_checkunsigned
(
L
,
1
),
-
luaL_checkint
(
L
,
2
));
}
static
int
b_arshift
(
lua_State
*
L
)
{
b_uint
r
=
luaL_checkunsigned
(
L
,
1
);
int
i
=
luaL_checkint
(
L
,
2
);
if
(
i
<
0
||
!
(
r
&
((
b_uint
)
1
<<
(
LUA_NBITS
-
1
))))
return
b_shift
(
L
,
r
,
-
i
);
else
{
/* arithmetic shift for 'negative' number */
if
(
i
>=
LUA_NBITS
)
r
=
ALLONES
;
else
r
=
trim
((
r
>>
i
)
|
~
(
~
(
b_uint
)
0
>>
i
));
/* add signal bit */
lua_pushunsigned
(
L
,
r
);
return
1
;
}
}
static
int
b_rot
(
lua_State
*
L
,
int
i
)
{
b_uint
r
=
luaL_checkunsigned
(
L
,
1
);
i
&=
(
LUA_NBITS
-
1
);
/* i = i % NBITS */
r
=
trim
(
r
);
r
=
(
r
<<
i
)
|
(
r
>>
(
LUA_NBITS
-
i
));
lua_pushunsigned
(
L
,
trim
(
r
));
return
1
;
}
static
int
b_lrot
(
lua_State
*
L
)
{
return
b_rot
(
L
,
luaL_checkint
(
L
,
2
));
}
static
int
b_rrot
(
lua_State
*
L
)
{
return
b_rot
(
L
,
-
luaL_checkint
(
L
,
2
));
}
/*
** get field and width arguments for field-manipulation functions,
** checking whether they are valid.
** ('luaL_error' called without 'return' to avoid later warnings about
** 'width' being used uninitialized.)
*/
static
int
fieldargs
(
lua_State
*
L
,
int
farg
,
int
*
width
)
{
int
f
=
luaL_checkint
(
L
,
farg
);
int
w
=
luaL_optint
(
L
,
farg
+
1
,
1
);
luaL_argcheck
(
L
,
0
<=
f
,
farg
,
"field cannot be negative"
);
luaL_argcheck
(
L
,
0
<
w
,
farg
+
1
,
"width must be positive"
);
if
(
f
+
w
>
LUA_NBITS
)
luaL_error
(
L
,
"trying to access non-existent bits"
);
*
width
=
w
;
return
f
;
}
static
int
b_extract
(
lua_State
*
L
)
{
int
w
;
b_uint
r
=
luaL_checkunsigned
(
L
,
1
);
int
f
=
fieldargs
(
L
,
2
,
&
w
);
r
=
(
r
>>
f
)
&
mask
(
w
);
lua_pushunsigned
(
L
,
r
);
return
1
;
}
static
int
b_replace
(
lua_State
*
L
)
{
int
w
;
b_uint
r
=
luaL_checkunsigned
(
L
,
1
);
b_uint
v
=
luaL_checkunsigned
(
L
,
2
);
int
f
=
fieldargs
(
L
,
3
,
&
w
);
int
m
=
mask
(
w
);
v
&=
m
;
/* erase bits outside given width */
r
=
(
r
&
~
(
m
<<
f
))
|
(
v
<<
f
);
lua_pushunsigned
(
L
,
r
);
return
1
;
}
static
const
luaL_Reg
bitlib
[]
=
{
{
"arshift"
,
b_arshift
},
{
"band"
,
b_and
},
{
"bnot"
,
b_not
},
{
"bor"
,
b_or
},
{
"bxor"
,
b_xor
},
{
"btest"
,
b_test
},
{
"extract"
,
b_extract
},
{
"lrotate"
,
b_lrot
},
{
"lshift"
,
b_lshift
},
{
"replace"
,
b_replace
},
{
"rrotate"
,
b_rrot
},
{
"rshift"
,
b_rshift
},
{
NULL
,
NULL
}
};
LUAMOD_API
int
luaopen_bit32
(
lua_State
*
L
)
{
luaL_newlib
(
L
,
bitlib
);
return
1
;
}
src/mod/languages/mod_lua/lua/lcorolib.c
0 → 100644
浏览文件 @
81a48a9e
/*
** $Id: lcorolib.c,v 1.5 2013/02/21 13:44:53 roberto Exp $
** Coroutine Library
** See Copyright Notice in lua.h
*/
#include <stdlib.h>
#define lcorolib_c
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
static
int
auxresume
(
lua_State
*
L
,
lua_State
*
co
,
int
narg
)
{
int
status
;
if
(
!
lua_checkstack
(
co
,
narg
))
{
lua_pushliteral
(
L
,
"too many arguments to resume"
);
return
-
1
;
/* error flag */
}
if
(
lua_status
(
co
)
==
LUA_OK
&&
lua_gettop
(
co
)
==
0
)
{
lua_pushliteral
(
L
,
"cannot resume dead coroutine"
);
return
-
1
;
/* error flag */
}
lua_xmove
(
L
,
co
,
narg
);
status
=
lua_resume
(
co
,
L
,
narg
);
if
(
status
==
LUA_OK
||
status
==
LUA_YIELD
)
{
int
nres
=
lua_gettop
(
co
);
if
(
!
lua_checkstack
(
L
,
nres
+
1
))
{
lua_pop
(
co
,
nres
);
/* remove results anyway */
lua_pushliteral
(
L
,
"too many results to resume"
);
return
-
1
;
/* error flag */
}
lua_xmove
(
co
,
L
,
nres
);
/* move yielded values */
return
nres
;
}
else
{
lua_xmove
(
co
,
L
,
1
);
/* move error message */
return
-
1
;
/* error flag */
}
}
static
int
luaB_coresume
(
lua_State
*
L
)
{
lua_State
*
co
=
lua_tothread
(
L
,
1
);
int
r
;
luaL_argcheck
(
L
,
co
,
1
,
"coroutine expected"
);
r
=
auxresume
(
L
,
co
,
lua_gettop
(
L
)
-
1
);
if
(
r
<
0
)
{
lua_pushboolean
(
L
,
0
);
lua_insert
(
L
,
-
2
);
return
2
;
/* return false + error message */
}
else
{
lua_pushboolean
(
L
,
1
);
lua_insert
(
L
,
-
(
r
+
1
));
return
r
+
1
;
/* return true + `resume' returns */
}
}
static
int
luaB_auxwrap
(
lua_State
*
L
)
{
lua_State
*
co
=
lua_tothread
(
L
,
lua_upvalueindex
(
1
));
int
r
=
auxresume
(
L
,
co
,
lua_gettop
(
L
));
if
(
r
<
0
)
{
if
(
lua_isstring
(
L
,
-
1
))
{
/* error object is a string? */
luaL_where
(
L
,
1
);
/* add extra info */
lua_insert
(
L
,
-
2
);
lua_concat
(
L
,
2
);
}
return
lua_error
(
L
);
/* propagate error */
}
return
r
;
}
static
int
luaB_cocreate
(
lua_State
*
L
)
{
lua_State
*
NL
;
luaL_checktype
(
L
,
1
,
LUA_TFUNCTION
);
NL
=
lua_newthread
(
L
);
lua_pushvalue
(
L
,
1
);
/* move function to top */
lua_xmove
(
L
,
NL
,
1
);
/* move function from L to NL */
return
1
;
}
static
int
luaB_cowrap
(
lua_State
*
L
)
{
luaB_cocreate
(
L
);
lua_pushcclosure
(
L
,
luaB_auxwrap
,
1
);
return
1
;
}
static
int
luaB_yield
(
lua_State
*
L
)
{
return
lua_yield
(
L
,
lua_gettop
(
L
));
}
static
int
luaB_costatus
(
lua_State
*
L
)
{
lua_State
*
co
=
lua_tothread
(
L
,
1
);
luaL_argcheck
(
L
,
co
,
1
,
"coroutine expected"
);
if
(
L
==
co
)
lua_pushliteral
(
L
,
"running"
);
else
{
switch
(
lua_status
(
co
))
{
case
LUA_YIELD
:
lua_pushliteral
(
L
,
"suspended"
);
break
;
case
LUA_OK
:
{
lua_Debug
ar
;
if
(
lua_getstack
(
co
,
0
,
&
ar
)
>
0
)
/* does it have frames? */
lua_pushliteral
(
L
,
"normal"
);
/* it is running */
else
if
(
lua_gettop
(
co
)
==
0
)
lua_pushliteral
(
L
,
"dead"
);
else
lua_pushliteral
(
L
,
"suspended"
);
/* initial state */
break
;
}
default:
/* some error occurred */
lua_pushliteral
(
L
,
"dead"
);
break
;
}
}
return
1
;
}
static
int
luaB_corunning
(
lua_State
*
L
)
{
int
ismain
=
lua_pushthread
(
L
);
lua_pushboolean
(
L
,
ismain
);
return
2
;
}
static
const
luaL_Reg
co_funcs
[]
=
{
{
"create"
,
luaB_cocreate
},
{
"resume"
,
luaB_coresume
},
{
"running"
,
luaB_corunning
},
{
"status"
,
luaB_costatus
},
{
"wrap"
,
luaB_cowrap
},
{
"yield"
,
luaB_yield
},
{
NULL
,
NULL
}
};
LUAMOD_API
int
luaopen_coroutine
(
lua_State
*
L
)
{
luaL_newlib
(
L
,
co_funcs
);
return
1
;
}
src/mod/languages/mod_lua/lua/lctype.c
0 → 100644
浏览文件 @
81a48a9e
/*
** $Id: lctype.c,v 1.11 2011/10/03 16:19:23 roberto Exp $
** 'ctype' functions for Lua
** See Copyright Notice in lua.h
*/
#define lctype_c
#define LUA_CORE
#include "lctype.h"
#if !LUA_USE_CTYPE
/* { */
#include <limits.h>
LUAI_DDEF
const
lu_byte
luai_ctype_
[
UCHAR_MAX
+
2
]
=
{
0x00
,
/* EOZ */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* 0. */
0x00
,
0x08
,
0x08
,
0x08
,
0x08
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* 1. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x0c
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
/* 2. */
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x16
,
0x16
,
0x16
,
0x16
,
0x16
,
0x16
,
0x16
,
0x16
,
/* 3. */
0x16
,
0x16
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x04
,
0x15
,
0x15
,
0x15
,
0x15
,
0x15
,
0x15
,
0x05
,
/* 4. */
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
/* 5. */
0x05
,
0x05
,
0x05
,
0x04
,
0x04
,
0x04
,
0x04
,
0x05
,
0x04
,
0x15
,
0x15
,
0x15
,
0x15
,
0x15
,
0x15
,
0x05
,
/* 6. */
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
0x05
,
/* 7. */
0x05
,
0x05
,
0x05
,
0x04
,
0x04
,
0x04
,
0x04
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* 8. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* 9. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* a. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* b. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* c. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* d. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* e. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
/* f. */
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
};
#endif
/* } */
src/mod/languages/mod_lua/lua/lctype.h
0 → 100644
浏览文件 @
81a48a9e
/*
** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $
** 'ctype' functions for Lua
** See Copyright Notice in lua.h
*/
#ifndef lctype_h
#define lctype_h
#include "lua.h"
/*
** WARNING: the functions defined here do not necessarily correspond
** to the similar functions in the standard C ctype.h. They are
** optimized for the specific needs of Lua
*/
#if !defined(LUA_USE_CTYPE)
#if 'A' == 65 && '0' == 48
/* ASCII case: can use its own tables; faster and fixed */
#define LUA_USE_CTYPE 0
#else
/* must use standard C ctype */
#define LUA_USE_CTYPE 1
#endif
#endif
#if !LUA_USE_CTYPE
/* { */
#include <limits.h>
#include "llimits.h"
#define ALPHABIT 0
#define DIGITBIT 1
#define PRINTBIT 2
#define SPACEBIT 3
#define XDIGITBIT 4
#define MASK(B) (1 << (B))
/*
** add 1 to char to allow index -1 (EOZ)
*/
#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
/*
** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
*/
#define lislalpha(c) testprop(c, MASK(ALPHABIT))
#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
#define lisdigit(c) testprop(c, MASK(DIGITBIT))
#define lisspace(c) testprop(c, MASK(SPACEBIT))
#define lisprint(c) testprop(c, MASK(PRINTBIT))
#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
/*
** this 'ltolower' only works for alphabetic characters
*/
#define ltolower(c) ((c) | ('A' ^ 'a'))
/* two more entries for 0 and -1 (EOZ) */
LUAI_DDEC
const
lu_byte
luai_ctype_
[
UCHAR_MAX
+
2
];
#else
/* }{ */
/*
** use standard C ctypes
*/
#include <ctype.h>
#define lislalpha(c) (isalpha(c) || (c) == '_')
#define lislalnum(c) (isalnum(c) || (c) == '_')
#define lisdigit(c) (isdigit(c))
#define lisspace(c) (isspace(c))
#define lisprint(c) (isprint(c))
#define lisxdigit(c) (isxdigit(c))
#define ltolower(c) (tolower(c))
#endif
/* } */
#endif
src/mod/languages/mod_lua/lua/lua.hpp
0 → 100644
浏览文件 @
81a48a9e
// lua.hpp
// Lua header files for C++
// <<extern "C">> not supplied automatically because Lua also compiles as C++
extern
"C"
{
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论