Lua??C/C++??????????????
???????????? ???????[ 2016/1/4 10:35:32 ] ??????????????????? .NET
???????????????????
func.lua
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
//lua????
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#define err_exit(num??fmt??args)
do{printf("[%s:%d]"fmt" "??__FILE__??__LINE__??##args);exit(num);} while(0)
#define err_return(num??fmt??args)
do{printf("[%s:%d]"fmt" "??__FILE__??__LINE__??##args);return(num);} while(0)
//lua?е????c???????壬?????
int csum(lua_State* l)
{
int a = lua_tointeger(l??1) ;
int b = lua_tointeger(l??2) ;
lua_pushinteger(l??a+b) ;
return 1 ;
}
int main(int argc??char** argv)
{
lua_State * l = luaL_newstate() ;
//????lua???л???
if ( l == NULL ) err_return(-1??"luaL_newstat() failed");
int ret = 0 ;
ret = luaL_loadfile(l??"func.lua") ;
//????lua??????
if ( ret != 0 ) err_return(-1??"luaL_loadfile failed") ;
ret = lua_pcall(l??0??0??0) ;
if ( ret != 0 ) err_return(-1??"lua_pcall failed:%s"??lua_tostring(l??-1)) ;
lua_getglobal(l??"width");
//???lua?ж???????
lua_getglobal(l??"height");
printf("height:%ld width:%ld "??lua_tointeger(l??-1)??lua_tointeger(l??-2)) ;
lua_pop(l??1) ;
//???lua???
int a = 11 ;
int b = 12 ;
lua_getglobal(l??"sum");
//????lua?е????sum
lua_pushinteger(l??a) ;
lua_pushinteger(l??b) ;
ret = lua_pcall(l??2??1??0) ;
if ( ret != 0 ) err_return(-1??"lua_pcall failed:%s"??lua_tostring(l??-1)) ;
printf("sum:%d + %d = %ld "??a??b??lua_tointeger(l??-1)) ;
lua_pop(l??1) ;
const char str1[] = "hello" ;
const char str2[] = "world" ;
lua_getglobal(l??"mystrcat");
//????lua?е????mystrcat
lua_pushstring(l??str1) ;
lua_pushstring(l??str2) ;
ret = lua_pcall(l??2??1??0) ;
if ( ret != 0 ) err_return(-1??"lua_pcall failed:%s"??lua_tostring(l??-1)) ;
printf("mystrcat:%s%s = %s "??str1??str2??lua_tostring(l??-1)) ;
lua_pop(l??1) ;
lua_pushcfunction(l??csum) ;
//?????lua??????c????
lua_setglobal(l??"csum") ;
//????lua?е?????csum
lua_getglobal(l??"mysum");
//????lua?е?mysum???????ú?????????????ж????csum?????????
lua_pushinteger(l??a) ;
lua_pushinteger(l??b) ;
ret = lua_pcall(l??2??1??0) ;
if ( ret != 0 ) err_return(-1??"lua_pcall failed:%s"??lua_tostring(l??-1)) ;
printf("mysum:%d + %d = %ld "??a??b??lua_tointeger(l??-1)) ;
lua_pop(l??1) ;
lua_close(l) ;
//???lua???л???
return 0 ;
}
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
??C++????????????C++ lvalue??rvalueC++11????????C++???????????????C++?е?????????????????C++?????????C++???Windows????λ??C/C++???????????????????JAVA??C??C++??????????c++??python???????????????????????????????C++???????C++?е????????C++????????????????C++ ???????????????C++?????????????????????C++????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????