Commit Graph

184 Commits

Author SHA1 Message Date
Glenn Maynard f45875adc7 add helpers 2007-02-04 08:03:47 +00:00
Glenn Maynard 510f900d28 lua.RunWithThreadVariables: Lua interface to LuaThreadVariables 2007-02-03 10:20:15 +00:00
Glenn Maynard b5d4997c9f gcc-like error messages; easier to read 2007-01-14 00:30:57 +00:00
Glenn Maynard 9c4357fe45 use for 2007-01-14 00:28:05 +00:00
Glenn Maynard 271dfafc8d pass error handler to lua_pcall 2007-01-14 00:25:40 +00:00
Glenn Maynard dd5baec8a5 split error message handler out of LuaPanic 2007-01-14 00:22:51 +00:00
Glenn Maynard c80639acbd remove LuaFunctionList 2007-01-14 00:20:16 +00:00
Glenn Maynard 1bd7c3c480 call luaopen() functions through Lua 2006-11-09 03:52:59 +00:00
Glenn Maynard dab10ec033 const 2006-11-02 05:47:32 +00:00
Glenn Maynard 854b259ef1 Replace actor parameters with thread variables.
This is to provide parameters to loading Actor definitions, in a way that
does not need to be explicitly propagated to nested definitions; I want
loading a sub-definition to remain a simple function call with no mandatory
(prescribed) parameters.  This provides a general context to pass information
to Lua about what it's loading, such as LoadingScreen.

These are scoped to the running thread, unlike global variables.  This prevents
possible threading problems.

All thread variables are scoped: set a variable, do something, unset it; when
finished, all thread variables are unset.

These are no longer available after load.  By design, to use these later,
use upvalues:

local color = lua.GetVar("color");
return Def.Quad {
    OnCommand=cmd(diffuse,color);
}
2006-11-02 04:23:19 +00:00
Glenn Maynard 708fa0166e move lock into pImpl 2006-10-31 01:23:25 +00:00
Glenn Maynard f9496f96d9 remove another specialized "parse and evaluate string" 2006-10-29 20:52:25 +00:00
Glenn Maynard ff2b6f697c PrepareExpression only used in one place and simple; merge down 2006-10-29 20:48:02 +00:00
Glenn Maynard 42583a63d5 remove bFirstParamIsString 2006-10-23 21:13:51 +00:00
Glenn Maynard 6636b13eb7 remove queuecommandm hack 2006-10-23 21:04:07 +00:00
Glenn Maynard 99a26fe6bc remove queuemessage hack 2006-10-23 21:02:17 +00:00
Glenn Maynard 7a912fc728 remove effectclock hack 2006-10-23 20:59:10 +00:00
Glenn Maynard 6327074f99 remove comment hacks 2006-10-23 20:54:53 +00:00
Glenn Maynard e246824ce3 remove ugly RunAtExpressionS 2006-10-23 20:40:32 +00:00
Glenn Maynard e5c216c8f0 remove unused (way too many little custom ways of loading Lua scripts) 2006-10-23 20:25:20 +00:00
Glenn Maynard 0ebc4a9900 header cleanup 2006-10-23 20:18:28 +00:00
Glenn Maynard e76a9c8965 remove parent parameter. Use self:GetParent(). 2006-10-23 09:14:27 +00:00
Glenn Maynard 84dc84627b fix clean shutdown on abort (dtor order problem) 2006-10-15 20:50:27 +00:00
Steve Checkoway 28df192f43 Remove debugging. 2006-10-15 08:07:34 +00:00
Steve Checkoway 1948d57161 Simplify. 2006-10-15 07:51:38 +00:00
Glenn Maynard 8e34463f78 assert 2006-10-15 05:31:44 +00:00
Glenn Maynard 54698735cd don't bother asserting here; states commonly still active when aborting from a dialog 2006-10-15 04:49:18 +00:00
Steve Checkoway a183541eed Use FOREACH_LUATABLE. 2006-10-15 03:16:06 +00:00
Glenn Maynard 4be14b7f50 bind "lua.ReadFile" 2006-10-15 02:35:33 +00:00
Glenn Maynard c8a8572a21 Allow yielding the Lua engine. This fixes a long-standing limitation
with Lua bindings: they couldn't read from disk, or render, or do anything
else potentially time-consuming, because that would hold the Lua lock,
preventing other threads from using it.
2006-10-15 01:58:36 +00:00
Glenn Maynard 10b96b08b8 LuaHelpers::DeepCopy 2006-10-15 01:40:11 +00:00
Glenn Maynard fe2b5f8e17 fix error case 2006-10-15 01:17:30 +00:00
Glenn Maynard 71af20fdf8 allow passing params to RunScript 2006-10-15 01:14:32 +00:00
Glenn Maynard 9fc246d64c remove unused 2006-10-14 22:36:16 +00:00
Glenn Maynard 82233e2ae7 Maintain multiple Lua states. Return an unused one for each LUA->Get()
call.

 - this means that nested calls which use Lua in unrelated, black boxed
   ways (and so don't pass around an *L) don't share a stack; when you
   Get a new state, you're guaranteed an empty stack, and like function
   dispatches, you can use absolute stack indexes starting from 1
 - we don't have to track stack counts to sanity check it; it always starts
   at 0, so just check that the stack is empty again on Release
 - we maintain a pool of states, so Get() is still fast; we typically create
   only a couple states
2006-10-14 22:34:15 +00:00
Glenn Maynard 3dc13b568a LuaManager::L -> m_pLuaMain 2006-10-14 20:49:35 +00:00
Glenn Maynard 48d3733296 lock for consistency 2006-10-14 20:37:30 +00:00
Glenn Maynard 89b435ef51 LuaManager::GetLuaInformation -> LuaHelpers::GetLuaInformation 2006-10-14 20:35:32 +00:00
Glenn Maynard 4276c87b67 this needs to lock, like everything else 2006-10-14 20:33:08 +00:00
Glenn Maynard 3ddbf641ac fix some error messages 2006-10-14 02:27:49 +00:00
Glenn Maynard 61ba92a933 bind Warn 2006-10-14 02:26:33 +00:00
Glenn Maynard 651c7ca15e simplify; use luaL_loadbuffer 2006-10-13 20:41:33 +00:00
Glenn Maynard 52edd053bd enable debug library 2006-10-09 07:28:01 +00:00
Glenn Maynard d0ab27b056 simplify 2006-10-09 05:43:24 +00:00
Glenn Maynard d7776aba60 evaluate enums directly 2006-10-09 01:34:16 +00:00
Glenn Maynard 6322ded0dc move command parsing into LuaHelpers. It's not Actor-specific other
than a few compatibility hacks.
2006-10-08 22:24:15 +00:00
Glenn Maynard 4b30d3552d A bizarre C++ wart wants us to declare FromStack overloads
before the ThemeMetric templates that use them.  That's broken
and unreasonable, so change this around a bit and make FromStack
(and Push) templates.

Push() takes a bit of a trick.  Some Push overloads push the
actual value: scalars (int, float), RageColor (pushes a table).
Others--most of them--push a reference to a C++ object.  We
want the scalars to have a reference parameter type, so we
don't make extra copies of things like RageColor when we push
them.  We need to pass C++ objects by pointer (we need to
push the actual object's pointer, not a pointer to a copy).
Further, pushing a scalar is a const operation, but pushing
a reference to an object is not.

To do both with the same template, we handle objects with
this slightly odd template:

template<> void LuaHelpers::Push<T*>( lua_State *L, T *const &pObject );

The actual overload (T) is eg. "Actor*"; this fits within the
general prototype, "Push(lua_State *L, const T &object)", giving
us a const reference to a (non-const) pointer to Actor, and we're
conceptually pushing the pointer.

The net effect of this is that 1: what was before compile errors
now becomes link time errors, but 2: these specializations
don't have to be in the headers (except for new ones for
Preference and BroadcastOnChange).
2006-10-07 01:22:28 +00:00
Glenn Maynard c72ae3bad7 use luaL_pushtype 2006-10-06 01:15:31 +00:00
Glenn Maynard 76dea048fc __type 2006-10-06 01:07:53 +00:00
Glenn Maynard c2a88f95cc fix enums 2006-10-06 00:46:46 +00:00