本文整理汇总了C++中runargs函数的典型用法代码示例。如果您正苦于以下问题:C++ runargs函数的具体用法?C++ runargs怎么用?C++ runargs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runargs函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pmain
static int pmain (lua_State *L) {
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
int script;
int has_i = 0, has_v = 0, has_e = 0;
if (argv[0] && argv[0][0]) progname = argv[0];
script = collectargs(argv, &has_i, &has_v, &has_e);
if (script < 0) { /* invalid arg? */
print_usage(argv[-script]);
return 0;
}
if (has_v) print_version();
/* open standard libraries */
luaL_checkversion(L);
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);
/* run LUA_INIT */
if (handle_luainit(L) != LUA_OK) return 0;
/* execute arguments -e and -l */
if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;
/* execute main script (if there is one) */
if (script && handle_script(L, argv, script) != LUA_OK) return 0;
if (has_i) /* -i option? */
dotty(L);
else if (script == 0 && !has_e && !has_v) { /* no arguments? */
if (lua_stdin_is_tty()) {
print_version();
dotty(L);
}
else dofile(L, NULL); /* executes stdin as a file */
}
lua_pushboolean(L, 1); /* signal no errors */
return 1;
}
开发者ID:mabako,项目名称:iv-modlua,代码行数:35,代码来源:lua.c
示例2: pmain
static int pmain (lua_State *L) {
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
char **argv = s->argv;
int script;
int has_i = 0, has_v = 0, has_e = 0;
globalL = L;
if (argv[0] && argv[0][0]) progname = argv[0];
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);
s->status = handle_luainit(L);
if (s->status != 0) return 0;
script = collectargs(argv, &has_i, &has_v, &has_e);
if (script < 0) { /* invalid args? */
print_usage();
s->status = 1;
return 0;
}
if (has_v) print_version();
s->status = runargs(L, argv, (script > 0) ? script : s->argc);
if (s->status != 0) return 0;
if (script)
s->status = handle_script(L, argv, script);
if (s->status != 0) return 0;
if (has_i)
dotty(L);
else if (script == 0 && !has_e && !has_v) {
if (lua_stdin_is_tty()) {
print_version();
dotty(L);
}
else dofile(L, NULL); /* executes stdin as a file */
}
return 0;
}
开发者ID:andyvand,项目名称:UltraDefrag,代码行数:35,代码来源:lua.c
示例3: pmain
static int pmain(lua_State *L)
{
int argc = (int)lua_tointeger(L, 1);
char **argv = (char**)lua_touserdata(L, 2);
int script;
int args[num_has];
args[has_i] = args[has_v] = args[has_e] = args[has_E] = 0;
if (argv[0] && argv[0][0])
progname = argv[0];
script = collectargs(argv, args);
if (script < 0) /* invalid arg? */
{
print_usage(argv[-script]);
return 0;
}
if (args[has_v])
print_version();
if (args[has_E]) /* option '-E'? */
{
lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
/* open standard libraries */
luaL_checkversion(L);
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);
if (!args[has_E] && handle_luainit(L) != LUA_OK)
return 0; /* error running LUA_INIT */
/* execute arguments -e and -l */
if (!runargs(L, argv, (script > 0) ? script : argc))
return 0;
/* execute main script (if there is one) */
if (script && handle_script(L, argv, script) != LUA_OK)
return 0;
if (args[has_i]) /* -i option? */
dotty(L);
else if (script == 0 && !args[has_e] && !args[has_v]) /* no arguments? */
{
if (lua_stdin_is_tty())
{
print_version();
dotty(L);
}
else
dofile(L, NULL); /* executes stdin as a file */
}
lua_pushboolean(L, 1); /* signal no errors */
return 1;
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:59,代码来源:lua.c
示例4: pmain
static int pmain(lua_State *L)
{
struct Smain *s = &smain;
char **argv = s->argv;
int script;
int flags = 0;
globalL = L;
if (argv[0] && argv[0][0]) progname = argv[0];
LUAJIT_VERSION_SYM(); /* linker-enforced version check */
script = collectargs(argv, &flags);
if (script < 0) { /* invalid args? */
print_usage();
s->status = 1;
return 0;
}
if ((flags & FLAGS_NOENV)) {
lua_pushboolean(L, 1);
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
s->status = tvm_loadbufferx(L, luaJIT_BC_op, luaJIT_BC_op_SIZE, "op", "b")
|| docall(L, 0, 1);
if (s->status != 0) return 0;
s->status = tvm_loadbufferx(L, luaJIT_BC_parse, luaJIT_BC_parse_SIZE, "parse", "b")
|| docall(L, 0, 1);
if (s->status != 0) return 0;
s->status = tvm_loadbufferx(L, luaJIT_BC_lunokhod, luaJIT_BC_lunokhod_SIZE, "lunokhod", "b")
|| docall(L, 0, 1);
if (s->status != 0) return 0;
lua_gc(L, LUA_GCRESTART, -1);
if (!(flags & FLAGS_NOENV)) {
s->status = handle_luainit(L);
if (s->status != 0) return 0;
}
if ((flags & FLAGS_VERSION)) print_version();
s->status = runargs(L, argv, (script > 0) ? script : s->argc);
if (s->status != 0) return 0;
if (script) {
s->status = handle_script(L, argv, script);
if (s->status != 0) return 0;
}
if ((flags & FLAGS_INTERACTIVE)) {
print_jit_status(L);
dotty(L);
} else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
if (lua_stdin_is_tty()) {
print_version();
print_jit_status(L);
dotty(L);
} else {
dofile(L, NULL); /* executes stdin as a file */
}
}
return 0;
}
开发者ID:pfalcon-mirrors,项目名称:tvmjit,代码行数:56,代码来源:tvmjit.c
示例5: pmain
/*
** Main body of stand-alone interpreter (to be called in protected mode).
** Reads the options and handles them all.
*/
static int pmain (lua_State *L) {
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
int script;
int args = collectargs(argv, &script);
luaL_checkversion(L); /* check that interpreter has correct version */
if (argv[0] && argv[0][0]) progname = argv[0];
#if 0
if (args == has_error) { /* bad arg? */
print_usage(argv[script]); /* 'script' has index of bad arg. */
return 0;
}
#endif
if (args & has_v) /* option '-v'? */
print_version();
if (args & has_E) { /* option '-E'? */
lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
luaL_openlibs(L); /* open standard libraries */
createargtable(L, argv, argc, script); /* create table 'arg' */
if (!(args & has_E)) { /* no option '-E'? */
if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */
return 0; /* error running LUA_INIT */
}
if (!runargs(L, argv, script)) /* execute arguments -e and -l */
return 0; /* something failed */
if (script < argc && /* execute main script (if there is one) */
handle_script(L, argv + script) != LUA_OK)
return 0;
#if 0
if (args & has_i) /* -i option? */
doREPL(L); /* do read-eval-print loop */
else if (script == argc && !(args & (has_e | has_v))) { /* no arguments? */
if (lua_stdin_is_tty()) { /* running in interactive mode? */
print_version();
doREPL(L); /* do read-eval-print loop */
}
else dofile(L, NULL); /* executes stdin as a file */
}
#endif
lua_pushboolean(L, 1); /* signal no errors */
return 1;
}
开发者ID:141141,项目名称:nodemcu-firmware-lua5.3.0,代码行数:48,代码来源:lua.c
示例6: pmain
/*
** 独立主函数的解释器(在保护模式下被调用)
** 读取选项参数并且处理他们
*/
static int pmain (lua_State *L) {
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
int script;
int args = collectargs(argv, &script);
luaL_checkversion(L); /* 检查解释器的版本*/
if (argv[0] && argv[0][0]) progname = argv[0];
if (args == has_error) { /* 坏变量? */
print_usage(argv[script]); /* '脚本'存在坏的变量 */
return 0;
}
if (args & has_v) /* 带有选项参数 '-v'? */
print_version();
if (args & has_E) { /* 带有选项参数 '-E'? */
lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
luaL_openlibs(L); /* 打开标准库 */
createargtable(L, argv, argc, script); /* 创建表 'arg' */
if (!(args & has_E)) { /* 没有选项'-E'? */
if (handle_luainit(L) != LUA_OK) /* 执行LUA_INIT */
return 0; /* error running LUA_INIT */
}
if (!runargs(L, argv, script)) /* 执行选项参数 -e and -l */
return 0; /* something failed */
if (script < argc && /**************************************** 执行主脚本 (如果有一个),这里是重点 *************************************/
handle_script(L, argv + script) != LUA_OK)
return 0;
if (args & has_i) /* -i 选项参数? */
doREPL(L); /* do read-eval-print loop 交互模式,即读取->运算->输出循环 */
else if (script == argc && !(args & (has_e | has_v))) { /* 没有参数? */
if (lua_stdin_is_tty()) { /* 交互模式运行? */
print_version();
doREPL(L); /* do read-eval-print loop 交互模式,即读取->运算->输出循环*/
}
else dofile(L, NULL); /* 执行stdin as a file */
}
lua_pushboolean(L, 1); /* signal no errors */
return 1;
}
开发者ID:liangxiegame,项目名称:lua,代码行数:44,代码来源:lua.c
示例7: pmain
static int pmain(lua_State *L)
{
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
char **argv = s->argv;
int script;
int flags = 0;
globalL = L;
if (argv[0] && argv[0][0]) progname = argv[0];
LUAJIT_VERSION_SYM(); /* linker-enforced version check */
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, -1);
s->status = handle_luainit(L);
if (s->status != 0) return 0;
script = collectargs(argv, &flags);
if (script < 0) { /* invalid args? */
print_usage();
s->status = 1;
return 0;
}
if ((flags & FLAGS_VERSION)) print_version();
s->status = runargs(L, argv, (script > 0) ? script : s->argc);
if (s->status != 0) return 0;
if (script)
s->status = handle_script(L, argv, script);
if (s->status != 0) return 0;
if ((flags & FLAGS_INTERACTIVE)) {
print_jit_status(L);
dotty(L);
} else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
if (lua_stdin_is_tty()) {
print_version();
print_jit_status(L);
dotty(L);
} else {
dofile(L, NULL); /* executes stdin as a file */
}
}
return 0;
}
开发者ID:loveshell,项目名称:ironbee,代码行数:40,代码来源:luajit.c
示例8: pmain
static int pmain(lua_State *L)
{
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
char **argv = s->argv;
int script;
int flags = 0;
globalL = L;
if (argv[0] && argv[0][0]) progname = argv[0];
LUAJIT_VERSION_SYM(); /* linker-enforced version check */
script = collectargs(argv, &flags);
if (script < 0) { /* invalid args? */
print_usage();
s->status = 1;
return 0;
}
if ((flags & FLAGS_NOENV)) {
lua_pushboolean(L, 1);
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
/**************/
lua_pushstring(L, MULTIWIICL_VERSION);
lua_setglobal(L, "MULTIWIICL_VERSION");
extern int luaopen_lpeg(lua_State*);
lua_pushcfunction(L, luaopen_lpeg);
lua_call(L, 0, 0);
extern int luaopen_luaserial(lua_State*);
lua_pushcfunction(L, luaopen_luaserial);
lua_call(L, 0, 0);
extern int luaopen_linenoise(lua_State*);
lua_pushcfunction(L, luaopen_linenoise);
lua_call(L, 0, 1);
# include "Config.h"
if (dostring(L, (const char*)Config, "@Config")) {
printf("%s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
# include "MultiWii.h"
if (dostring(L, (const char*)MultiWii, "@MultiWii")) {
printf("%s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
/**************/
lua_gc(L, LUA_GCRESTART, -1);
if (!(flags & FLAGS_NOENV)) {
s->status = handle_luainit(L);
if (s->status != 0) return 0;
}
s->status = runargs(L, argv, (script > 0) ? script : s->argc);
if (s->status != 0) return 0;
if (script) {
s->status = handle_script(L, argv, script);
if (s->status != 0) return 0;
}
if ((flags & FLAGS_INTERACTIVE) || (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION)))) {
# include "Prompt.h"
if (dostring(L, (const char*)Prompt, "@Prompt")) {
printf("%s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
}
// if ((flags & FLAGS_VERSION)) print_version();
// s->status = runargs(L, argv, (script > 0) ? script : s->argc);
// if (s->status != 0) return 0;
// if (script) {
// s->status = handle_script(L, argv, script);
// if (s->status != 0) return 0;
// }
// if ((flags & FLAGS_INTERACTIVE)) {
// print_jit_status(L);
// dotty(L);
// } else if (script == 0 && !(flags & (FLAGS_EXEC|FLAGS_VERSION))) {
// if (lua_stdin_is_tty()) {
// print_version();
// print_jit_status(L);
// dotty(L);
// } else {
// dofile(L, NULL); /* executes stdin as a file */
// }
// }
return 0;
}
开发者ID:c---,项目名称:MultiWiiCL,代码行数:94,代码来源:luajit.c
示例9: pmain
static int pmain(lua_State *L)
{
struct Smain *s = &smain;
char **argv = s->argv;
int argn;
int flags = 0;
globalL = L;
if (argv[0] && argv[0][0]) progname = argv[0];
LUAJIT_VERSION_SYM(); /* Linker-enforced version check. */
argn = collectargs(argv, &flags);
if (argn < 0) { /* Invalid args? */
print_usage();
s->status = 1;
return 0;
}
if ((flags & FLAGS_NOENV)) {
lua_pushboolean(L, 1);
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
}
/* Set MAD env _before_ libraries are open. */
mad_setenv(L, flags & FLAGS_NOENV);
/* Stop collector during library initialization. */
lua_gc(L, LUA_GCSTOP, 0);
luaL_openlibs(L);
mad_openlibs(L);
lua_gc(L, LUA_GCRESTART, -1);
createargtable(L, argv, s->argc, argn);
if (!(flags & FLAGS_NOENV)) {
s->status = handle_luainit(L);
if (s->status != LUA_OK) return 0;
}
/* MAD section. */
mad_setsig();
mad_regfunc();
if ((flags & FLAGS_MADENV))
dolibrary(L, "madl_main");
if (!(flags & FLAGS_NOENV)) {
s->status = handle_madinit(L);
if (s->status != LUA_OK) return 0;
}
if ((flags & FLAGS_VERSION)) print_version();
s->status = runargs(L, argv, argn);
if (s->status != LUA_OK) return 0;
if (s->argc > argn) {
s->status = handle_script(L, argv + argn);
if (s->status != LUA_OK) return 0;
}
if ((flags & FLAGS_INTERACTIVE)) {
(void)print_jit_status;
dotty(L);
} else if (s->argc == argn && !(flags & FLAGS_EXEC)) {
if (lua_stdin_is_tty()) {
(void)print_version;
(void)print_jit_status;
dotty(L);
} else {
dofile(L, NULL); /* Executes stdin as a file. */
}
}
return 0;
}
开发者ID:MethodicalAcceleratorDesign,项目名称:MAD,代码行数:74,代码来源:mad_main.c
注:本文中的runargs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论