本文整理汇总了C++中docall函数的典型用法代码示例。如果您正苦于以下问题:C++ docall函数的具体用法?C++ docall怎么用?C++ docall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了docall函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doread
int
doread() {
register struct obj *scroll;
register boolean confused = (Confusion != 0);
known = FALSE;
scroll = getobj(readable, "read"); /* "#-" added by GAN 10/22/86 */
if(!scroll) return(0);
/* below added to allow reading of fortune cookies */
if(scroll->otyp == FORTUNE_COOKIE) {
if(flags.verbose)
You("break up the cookie and throw away the pieces.");
outrumor(bcsign(scroll), TRUE);
useup(scroll);
return(1);
} else
if(scroll->olet != SCROLL_SYM
#ifdef SPELLS
&& scroll->olet != SPBOOK_SYM
#endif
) {
pline("That is a silly thing to read.");
return(0);
}
if(Blind) {
#ifdef SPELLS
if (scroll->olet == SPBOOK_SYM) {
pline("Being blind, you cannot read the mystic runes.");
return(0);
} else
#endif
if (!scroll->dknown) {
pline("Being blind, you cannot read the formula on the scroll.");
return(0);
}
}
#ifndef NO_SIGNAL
scroll->in_use = TRUE; /* now being read */
#endif
#ifdef SPELLS
if(scroll->olet == SPBOOK_SYM) {
if(confused) {
You("cannot grasp the meaning of this tome.");
useup(scroll);
return(0);
} else
return(study_book(scroll));
}
#endif
if(scroll->otyp != SCR_BLANK_PAPER) {
if(Blind)
pline("As you pronounce the formula on it, the scroll disappears.");
else
pline("As you read the scroll, it disappears.");
if(confused) {
if (Hallucination)
pline("Being so trippy, you screw up...");
else
pline("Being confused, you mispronounce the magic words...");
}
}
if(!seffects(scroll)) {
if(!objects[scroll->otyp].oc_name_known) {
if(known && !confused) {
makeknown(scroll->otyp);
more_experienced(0,10);
} else if(!objects[scroll->otyp].oc_uname)
docall(scroll);
}
if(!(scroll->otyp == SCR_BLANK_PAPER) || confused)
useup(scroll);
#ifndef NO_SIGNAL
else scroll->in_use = FALSE;
#endif
}
return(1);
}
示例2: dostring
static int dostring (lua_State *L, const char *s, const char *name) {
int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1);
return report(L, status);
}
示例3: dostring
static int dostring (lua_State *L, const char *s, const char *name) {
int status = luaL_loadbuffer(L, s, strlen(s), name);
if (status == LUA_OK) status = docall(L, 0, 0);
return report(L, status);
}
示例4: call
inline Value call(Function func, const Value &arg0, const Value &arg1, const Value &arg2, const Value &arg3, const Value &arg4, const Value &arg5, const Value &arg6, const Value &arg7, const Value &arg8)
{
Value args[] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8};
return docall(func, 9, args);
}
示例5: dolibrary
static int dolibrary(lua_State *L, const char *name)
{
lua_getglobal(L, "require");
lua_pushstring(L, name);
return report(L, docall(L, 1, 1));
}
示例6: f_Comment
static void f_Comment (void *ud, const char *data) {
lxp_userdata *xpu = (lxp_userdata *)ud;
if (getHandle(xpu, CommentKey) == 0) return; /* no handle */
lua_pushstring(xpu->L, data);
docall(xpu, 1, 0);
}
示例7: f_DefaultExpand
static void f_DefaultExpand (void *ud, const char *data, int len) {
lxp_userdata *xpu = (lxp_userdata *)ud;
if (getHandle(xpu, DefaultExpandKey) == 0) return; /* no handle */
lua_pushlstring(xpu->L, data, len);
docall(xpu, 1, 0);
}
示例8: nlua_thread
static void
nlua_thread(int pin, int pout, char *project, char *filename)
{
char cmd[4096];
int cmd_size;
fprintf(stderr, "[err] Starting up Lua interpreter...\n");
fprintf(stdout, "[out] Starting up Lua interpreter...\n");
lua_State *L;
L = lua_open();
if (!L) {
cmd[0] = LC_ERROR;
cmd_size = snprintf(cmd+1, sizeof(cmd)-2, "Unable to open lua") + 1;
write(1, cmd, cmd_size);
exit(0);
}
luaL_openlibs(L);
lua_sethook(L, nlua_interpret_hook, LUA_MASKLINE, 0);
/* If a filename was specified, load it in and run it */
if (project && *project) {
char full_filename[2048];
if (filename && *filename)
snprintf(full_filename, sizeof(full_filename)-1,
"%s/%s/%s", PROJECT_DIR, project, filename);
else
snprintf(full_filename, sizeof(full_filename)-1,
"%s/%s", PROJECT_DIR, project);
if (luaL_dofile(L, full_filename)) {
cmd[0] = LC_ERROR;
cmd_size = snprintf(cmd+1, sizeof(cmd)-2, "Error: %s",
lua_tostring(L, 1)) + 1;
write(1, cmd, cmd_size);
}
}
/* If no file was specified, enter REPL mode */
else {
printf("Entering REPL mode...\n");
int status;
while ((status = loadline(L)) != -1) {
if (status == 0)
status = docall(L, 0, 0);
report(L, status);
if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
lua_getglobal(L, "print");
lua_insert(L, 1);
if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
l_message(progname,
lua_pushfstring(L, "error calling " LUA_QL("print") " (%s)",
lua_tostring(L, -1)));
}
}
lua_settop(L, 0);
fputs("\n", stdout);
fflush(stdout);
}
lua_close(L);
close(pin);
close(pout);
exit(0);
return;
}
示例9: f_EndCdataKey
static void f_EndCdataKey (void *ud) {
lxp_userdata *xpu = (lxp_userdata *)ud;
if (getHandle(xpu, EndCdataKey) == 0) return; /* no handle */
docall(xpu, 0, 0);
}
示例10: dolibrary
static int dolibrary (lua_State *L, const char *name) {
lua_getfield(L, LUA_ENVIRONINDEX, "require");
lua_pushstring(L, name);
return report(L, docall(L, 1, 1));
}
示例11: dodrink
//.........这里部分代码省略.........
goto outobjmap;
pline("You sense the presence of objects close nearby.");
break;
outobjmap:
cls();
for (objs = fobj; objs; objs = objs->nobj)
at(objs->ox, objs->oy, objs->olet);
prme();
pline("You sense the presence of objects.");
more();
docrt();
}
break;
case POT_SICKNESS:
pline("Yech! This stuff tastes like poison.");
if (Poison_resistance)
pline("(But in fact it was biologically contaminated orange juice.)");
losestr(rn1(4, 3));
losehp(rnd(10), "contaminated potion");
break;
case POT_CONFUSION:
if (!Confusion)
pline("Huh, What? Where am I?");
else
nothing++;
Confusion += rn1(7, 16);
break;
case POT_GAIN_STRENGTH:
pline("Wow do you feel strong!");
if (u.ustr >= 118)
break; /* > 118 is impossible */
if (u.ustr > 17)
u.ustr += rnd(118 - u.ustr);
else
u.ustr++;
if (u.ustr > u.ustrmax)
u.ustrmax = u.ustr;
flags.botl = 1;
break;
case POT_SPEED:
if (Wounded_legs) {
heal_legs();
unkn++;
break;
}
if (!(Fast & ~INTRINSIC))
pline("You are suddenly moving much faster.");
else
pline("Your legs get new energy."), unkn++;
Fast += rn1(10, 100);
break;
case POT_BLINDNESS:
if (!Blind)
pline("A cloud of darkness falls upon you.");
else
nothing++;
Blind += rn1(100, 250);
seeoff(0);
break;
case POT_GAIN_LEVEL:
pluslvl();
break;
case POT_EXTRA_HEALING:
pline("You feel much better.");
flags.botl = 1;
u.uhp += d(2, 20) + 1;
if (u.uhp > u.uhpmax)
u.uhp = (u.uhpmax += 2);
if (Blind)
Blind = 1;
if (Sick)
Sick = 0;
break;
case POT_LEVITATION:
if (!Levitation)
float_up();
else
nothing++;
Levitation += rnd(100);
u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down;
break;
default:
impossible("What a funny potion! (%u)", otmp->otyp);
return (0);
}
if (nothing) {
unkn++;
pline("You have a peculiar feeling for a moment, then it passes.");
}
if (otmp->dknown && !objects[otmp->otyp].oc_name_known) {
if (!unkn) {
objects[otmp->otyp].oc_name_known = 1;
more_experienced(0, 10);
} else if (!objects[otmp->otyp].oc_uname)
docall(otmp);
}
use_it:
useup(otmp);
return (1);
}
示例12: on_event
bool on_event(SDL_Event *event)
{
switch (event->type) {
case SDL_TEXTINPUT:
if (current_keyhandler != LUA_NOREF)
{
static Uint32 lastts = 0;
static char lastc = 0;
if (browsers_count) { // Somehow CEF3 makes keys sometime arrive duplicated, so prevent that here
if (event->text.timestamp == lastts) break;
if ((event->text.timestamp - lastts < 3) && (lastc == event->text.text[0])) break;
}
lastts = event->text.timestamp;
lastc = event->text.text[0];
lua_rawgeti(L, LUA_REGISTRYINDEX, current_keyhandler);
lua_pushstring(L, "receiveKey");
lua_gettable(L, -2);
lua_remove(L, -2);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_keyhandler);
lua_pushnumber(L, 0);
SDL_Keymod _pKeyState = SDL_GetModState();
lua_pushboolean(L, (_pKeyState & KMOD_CTRL) ? TRUE : FALSE);
lua_pushboolean(L, (_pKeyState & KMOD_SHIFT) ? TRUE : FALSE);
lua_pushboolean(L, (_pKeyState & KMOD_ALT) ? TRUE : FALSE);
lua_pushboolean(L, (_pKeyState & KMOD_GUI) ? TRUE : FALSE);
lua_pushstring(L, event->text.text);
lua_pushboolean(L, FALSE);
lua_pushnil(L);
lua_pushnil(L);
lua_pushnumber(L, 0);
docall(L, 11, 0);
}
return TRUE;
case SDL_KEYDOWN:
case SDL_KEYUP:
if (current_keyhandler != LUA_NOREF)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, current_keyhandler);
lua_pushstring(L, "receiveKey");
lua_gettable(L, -2);
lua_remove(L, -2);
lua_rawgeti(L, LUA_REGISTRYINDEX, current_keyhandler);
lua_pushnumber(L, event->key.keysym.scancode);
SDL_Keymod _pKeyState = SDL_GetModState();
lua_pushboolean(L, (_pKeyState & KMOD_CTRL) ? TRUE : FALSE);
lua_pushboolean(L, (_pKeyState & KMOD_SHIFT) ? TRUE : FALSE);
lua_pushboolean(L, (_pKeyState & KMOD_ALT) ? TRUE : FALSE);
lua_pushboolean(L, (_pKeyState & KMOD_GUI) ? TRUE : FALSE);
lua_pushnil(L);
lua_pushboolean(L, (event->type == SDL_KEYUP) ? TRUE : FALSE);
/* Convert unicode UCS-2 to UTF8 string */
if (event->key.keysym.sym)
{
wchar_t wc = event->key.keysym.sym;
char buf[4] = {0,0,0,0};
if (wc < 0x80)
{
buf[0] = wc;
}
else if (wc < 0x800)
{
buf[0] = (0xC0 | wc>>6);
buf[1] = (0x80 | (wc & 0x3F));
}
else
{
示例13: docall
/**@brief Call function with current self and other instances.*/
inline Value docall(Function f, unsigned argcnt, Value *args)
{
return docall(f, getSelf(), getOther(), argcnt, args);
}
示例14: f_EndElement
static void f_EndElement (void *ud, const char *name) {
lxp_userdata *xpu = (lxp_userdata *)ud;
if (getHandle(xpu, EndElementKey) == 0) return; /* no handle */
lua_pushstring(xpu->L, name);
docall(xpu, 1, 0);
}
示例15: f_EndNamespaceDecl
static void f_EndNamespaceDecl (void *ud, const char *prefix) {
lxp_userdata *xpu = (lxp_userdata *)ud;
if (getHandle(xpu, EndNamespaceDeclKey) == 0) return; /* no handle */
lua_pushstring(xpu->L, prefix);
docall(xpu, 1, 0);
}