Beispiel #1
0
void ScriptController::setFloat(const char* name, float v)
{
    lua_pushnumber(_lua, v);
    lua_setglobal(_lua, name);
}
Beispiel #2
0
static int math_exp (lua_State *L) {
  lua_pushnumber(L, exp(luaL_checknumber(L, 1)));
  return 1;
}
Beispiel #3
0
static int math_frexp (lua_State *L) {
  int e;
  lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e));
  lua_pushnumber(L, e);
  return 2;
}
Beispiel #4
0
/**	@name	getTimesExecuted
	@text	Gets the number of times the timer has completed a cycle.

	@in		MOAITimer self
	@out	number nTimes
*/
int MOAITimer::_getTimesExecuted ( lua_State* L ) {
    MOAI_LUA_SETUP ( MOAITimer, "UN" )

    lua_pushnumber ( L, self->mTimesExecuted );
    return 1;
}
int cosocket_be_write(se_ptr_t *ptr)
{
    cosocket_t *c*k = ptr->data;
    int n = 0, ret = 0;
    c*k->in_read_action = 0;

    if(!c*k->ssl) {
        while((n = send(c*k->fd, c*k->send_buf + c*k->send_buf_ed, c*k->send_buf_len - c*k->send_buf_ed, MSG_DONTWAIT)) > 0) {
            c*k->send_buf_ed += n;
        }

    } else {
        while((n = SSL_write(c*k->ssl, c*k->send_buf + c*k->send_buf_ed, c*k->send_buf_len - c*k->send_buf_ed)) > 0) {
            c*k->send_buf_ed += n;
        }
    }

    if(c*k->send_buf_ed == c*k->send_buf_len || (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK)) {
        if(n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
            se_delete(c*k->ptr);
            c*k->ptr = NULL;
            connection_pool_counter_operate(c*k->pool_key, -1);
            close(c*k->fd);
            c*k->fd = -1;
            c*k->status = 0;
            c*k->send_buf_ed = 0;

        }

        /* else {
            se_be_pri(c*k->ptr, NULL);
        }*/

        if(c*k->send_buf_need_free) {
            free(c*k->send_buf_need_free);
            c*k->send_buf_need_free = NULL;
        }

        delete_timeout(c*k->timeout_ptr);
        c*k->timeout_ptr = NULL;

        int rc = 1;

        if(c*k->send_buf_ed >= c*k->send_buf_len) {
            lua_pushnumber(c*k->L, c*k->send_buf_ed);

        } else if(c*k->fd == -1) {
            lua_pushnil(c*k->L);
            lua_pushstring(c*k->L, "connection closed!");
            rc = 2;

        } else {
            lua_pushboolean(c*k->L, 0);
        }

        if(c*k->inuse == 1) {
            se_be_pri(c*k->ptr, NULL);
            c*k->inuse = 0;
            lua_f_lua_uthread_resume_in_c(c*k->L, rc);
            return 0;

        } else {
            return 0 - rc;
        }
    }

    return c*k->send_buf_len - c*k->send_buf_ed;
}
Beispiel #6
0
static int os_difftime (lua_State *L) {
  lua_pushnumber(L, difftime((luaL_checknumber(L, 1)),
                             (luaL_optnumber(L, 2, 0))));
  return 1;
}
Beispiel #7
0
int vm_hw_lua_cpu_handle_register_get(lua_State* L)
{
	// Table is at 1, key is at 2.
	vm_t* vm = vm_hw_lua_cpu_extract_cpu(L, 1);
	bstring name = bfromcstr(lua_tostring(L, 2));

	if (biseqcstrcaseless(name, "A"))
		lua_pushnumber(L, vm->registers[REG_A]);
	else if (biseqcstrcaseless(name, "B"))
		lua_pushnumber(L, vm->registers[REG_B]);
	else if (biseqcstrcaseless(name, "C"))
		lua_pushnumber(L, vm->registers[REG_C]);
	else if (biseqcstrcaseless(name, "X"))
		lua_pushnumber(L, vm->registers[REG_X]);
	else if (biseqcstrcaseless(name, "Y"))
		lua_pushnumber(L, vm->registers[REG_Y]);
	else if (biseqcstrcaseless(name, "Z"))
		lua_pushnumber(L, vm->registers[REG_Z]);
	else if (biseqcstrcaseless(name, "I"))
		lua_pushnumber(L, vm->registers[REG_I]);
	else if (biseqcstrcaseless(name, "J"))
		lua_pushnumber(L, vm->registers[REG_J]);
	else if (biseqcstrcaseless(name, "SP"))
		lua_pushnumber(L, vm->sp);
	else if (biseqcstrcaseless(name, "PC"))
		lua_pushnumber(L, vm->pc);
	else if (biseqcstrcaseless(name, "IA"))
		lua_pushnumber(L, vm->ia);
	else if (biseqcstrcaseless(name, "EX"))
		lua_pushnumber(L, vm->ex);
	else
		lua_pushnil(L);

	return 1;
}
Beispiel #8
0
static int math_rad (lua_State *L) {
  lua_pushnumber(L, luaL_checknumber(L, 1) * (PI / l_mathop(180.0)));
  return 1;
}
Beispiel #9
0
static int math_sinh (lua_State *L) {
  lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1)));
  return 1;
}
inline void VLuaWrapper::PushParameter (float fParameter)
{
    lua_pushnumber (mp_State, fParameter);
    m_States.m_iParametersPushed++;
}
Beispiel #11
0
static int math_deg (lua_State *L) {
  lua_pushnumber(L, luaL_checknumber(L, 1) * (l_mathop(180.0) / PI));
  return 1;
}
inline void VLuaWrapper::setVariable (const char* szName, float fValue) const
{
    lua_pushnumber (mp_State, fValue);
    lua_setfield (mp_State, (m_States.m_iOpenTables == 0) ? LUA_GLOBALSINDEX : -2, szName);
}
Beispiel #13
0
static int thread_state (lua_State *L) {
   thread_t t=lstage_tothread(L,1);
   lua_pushnumber(L,t->state);
   return 1;
}
Beispiel #14
0
void ScriptController::setDouble(const char* name, double v)
{
    lua_pushnumber(_lua, v);
    lua_setglobal(_lua, name);
}
Beispiel #15
0
static int math_fmod (lua_State *L) {
  lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
  return 1;
}
Beispiel #16
0
static int math_pow (lua_State *L) {
  lua_Number x = luaL_checknumber(L, 1);
  lua_Number y = luaL_checknumber(L, 2);
  lua_pushnumber(L, l_mathop(pow)(x, y));
  return 1;
}
Beispiel #17
0
static int os_clock (lua_State *L) {
  lua_pushnumber(L, ((lua_Number)(1.0*clock()))/(lua_Number)CLOCKS_PER_SEC);
  return 1;
}
Beispiel #18
0
static int math_ldexp (lua_State *L) {
  lua_Number x = luaL_checknumber(L, 1);
  int ep = (int)luaL_checkinteger(L, 2);
  lua_pushnumber(L, l_mathop(ldexp)(x, ep));
  return 1;
}
Beispiel #19
0
int vm_hw_lua_cpu_disassemble(lua_State* L)
{
	vm_t* vm = vm_hw_lua_cpu_extract_cpu(L, 1);
	struct inst inst = vm_disassemble(vm, (uint16_t)luaL_checknumber(L, 2), true);
	lua_newtable(L);
	lua_newtable(L);
	lua_pushnumber(L, inst.original.full);
	lua_setfield(L, -2, "full");
	lua_pushnumber(L, inst.original.op);
	lua_setfield(L, -2, "op");
	lua_pushnumber(L, inst.original.a);
	lua_setfield(L, -2, "a");
	lua_pushnumber(L, inst.original.b);
	lua_setfield(L, -2, "b");
	lua_setfield(L, -2, "original");
	lua_newtable(L);
	if (inst.pretty.op != NULL)
		lua_pushstring(L, inst.pretty.op->data);
	else
		lua_pushnil(L);
	lua_setfield(L, -2, "op");
	if (inst.pretty.a != NULL)
		lua_pushstring(L, inst.pretty.a->data);
	else
		lua_pushnil(L);
	lua_setfield(L, -2, "a");
	if (inst.pretty.b != NULL)
		lua_pushstring(L, inst.pretty.b->data);
	else
		lua_pushnil(L);
	lua_setfield(L, -2, "b");
	lua_setfield(L, -2, "pretty");
	lua_pushnumber(L, inst.op);
	lua_setfield(L, -2, "op");
	lua_pushnumber(L, inst.a);
	lua_setfield(L, -2, "a");
	lua_pushnumber(L, inst.b);
	lua_setfield(L, -2, "b");
	lua_pushnumber(L, inst.size);
	lua_setfield(L, -2, "size");
	lua_newtable(L);
	if (inst.size >= 1)
	{
		lua_pushnumber(L, inst.extra[0]);
		lua_rawseti(L, -2, 1);
	}
	if (inst.size >= 2)
	{
		lua_pushnumber(L, inst.extra[1]);
		lua_rawseti(L, -2, 2);
	}
	lua_setfield(L, -2, "extra");
	lua_newtable(L);
	if (inst.used[0])
		lua_pushnumber(L, inst.next[0]);
	else
		lua_pushnil(L);
	lua_rawseti(L, -2, 1);
	if (inst.used[1])
		lua_pushnumber(L, inst.next[1]);
	else
		lua_pushnil(L);
	lua_rawseti(L, -2, 2);
	lua_setfield(L, -2, "next");
	bdestroy(inst.pretty.op);
	bdestroy(inst.pretty.a);
	bdestroy(inst.pretty.b);
	return 1;
}
Beispiel #20
0
static int math_tan (lua_State *L) {
  lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1)));
  return 1;
}
Beispiel #21
0
/**	@name	getTime
	@text	Return the current time.

	@in		MOAITimer self
	@out	number time
*/
int MOAITimer::_getTime( lua_State* L ) {
    MOAI_LUA_SETUP ( MOAITimer, "U" )

    lua_pushnumber ( L, self->mTime );
    return 1;
}
Beispiel #22
0
static int math_acos (lua_State *L) {
  lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1)));
  return 1;
}
int lua_co_getreusedtimes(lua_State *L)
{
    cosocket_t *c*k = (cosocket_t *) lua_touserdata(L, 1);
    lua_pushnumber(L, c*k->reusedtimes);
    return 1;
}
Beispiel #24
0
static int math_atan (lua_State *L) {
  lua_Number y = luaL_checknumber(L, 1);
  lua_Number x = luaL_optnumber(L, 2, 1);
  lua_pushnumber(L, l_mathop(atan2)(y, x));
  return 1;
}
Beispiel #25
0
static int math_log10 (lua_State *L) {
  lua_pushnumber(L, log10(luaL_checknumber(L, 1)));
  return 1;
}
Beispiel #26
0
static int math_atan2 (lua_State *L) {
  lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2)));
  return 1;
}
Beispiel #27
0
static int math_rad (lua_State *L) {
  lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE);
  return 1;
}
Beispiel #28
0
static int math_floor (lua_State *L) {
  lua_pushnumber(L, floor(luaL_checknumber(L, 1)));
  return 1;
}
Beispiel #29
0
static int math_ldexp (lua_State *L) {
  lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2)));
  return 1;
}
Beispiel #30
0
int DemoLoadFX(lua_State *pLuaState)
{
    int iFX = g_LuaPlayer->LoadFX(lua_tostring(pLuaState,1));
    lua_pushnumber(pLuaState,iFX);
    return 1;
}