ug4
|
Classes | |
class | LuaError |
Error class thrown if an error occurs during parsing. More... | |
Enumerations | |
enum | debug_return { DEBUG_EXIT =0 , DEBUG_CONTINUE , DEBUG_NEXT , DEBUG_STEP , DEBUG_FINISH } |
Functions | |
void | AddBreakpoint (const char *source, int line) |
void | breakpoint () |
void | breakpoint_in_script () |
void | CheckHook () |
void | DebugBacktrace (int fromLevel) |
lists the function stack in lua More... | |
void | DebugDown () |
move down function stack More... | |
void | DebugHold () |
void | DebugList () |
lists the current line in the script More... | |
void | DebugUp () |
move down function stack More... | |
void | FinalizeLUADebug () |
Free all memory associated with lua_debug. More... | |
UG_API bool | GetAbsoluteUGScriptFilename (const std::string &filename, std::string &absoluteFilename) |
bool | GetAbsoluteUGScriptFilename (const string &filename, string &absoluteFilename) |
std::string | GetAbsoluteUGScriptFilenamePaths () |
lua_State * | GetDefaultLuaState () |
returns the default lua state More... | |
int | getDepth () |
bool | GetNormalFilename (const string &filename, string &returnedFilename) |
static void | GetToStringFromStack (lua_State *L, std::stringstream &ss) |
bool | IsLUADebug () |
bool | LoadUGScript (const char *_filename, bool bDistributedLoad, bool bThrowOnError) |
UG_API bool | LoadUGScript (const char *filename, bool bDistributed) |
loads and parses a file. Several paths are tried if the file is not found. More... | |
bool | LoadUGScript_Parallel (const char *filename) |
calls LoadUGScript with bDistributed=true More... | |
bool | LoadUGScript_Single (const char *filename) |
calls LoadUGScript with bDistributed=false . Avoid. ( More... | |
void | LuaCallHook (lua_State *L, lua_Debug *ar) |
int | luaCallStackError (lua_State *L) |
error function to be used for lua_pcall More... | |
void | luaDebug (lua_State *L, const char *source, int line) |
bool | ParseAndExecuteBuffer (const char *buffer, const char *bufferName) |
void | PrintBreakpoints () |
void | ProfileLUA (bool b) |
void | RegisterDefaultLuaBridge (ug::bridge::Registry *reg, std::string grp="/ug4") |
registers lua only functionality at the registry More... | |
bool | RegisterLuaDebug (ug::bridge::Registry ®) |
void | RegisterStdLUAFunctions (lua_State *L) |
register functions like print and write directly to LUA (not using the ug registry) More... | |
void | ReleaseDefaultLuaState () |
calls lua_close, which calls delete for all lua objects More... | |
int | SetDebugShell (debug_return(*s)()) |
void | SetLuaDebug (lua_State *L, string id) |
void | SetLuaDebugIDs (lua_State *L) |
void | SetLuaUGArgs (lua_State *L, int argc, char *argv[]) |
int | UGAlgebraCompiled (lua_State *L) |
Returns if dimension is compiled into binary. More... | |
int | UGDimCompiled (lua_State *L) |
Returns if dimension is compiled into binary. More... | |
int | UGGetClassGroup (lua_State *L) |
Returns classgroup of a userdata as string. More... | |
int | UGGetClassName (lua_State *L) |
Returns type of a userdata as string. More... | |
int | UGGetMetatable (lua_State *L) |
Returns the metatable for the given class. More... | |
int | UGIsBaseClass (lua_State *L) |
Returns if a class contains a base class. More... | |
int | UGLuaErrLog (lua_State *L) |
UGLuaErrLog. More... | |
int | UGLuaPrint (lua_State *L) |
UGLuaPrint. Redirects LUA prints to UG_LOG. More... | |
int | UGLuaPrintAllProcs (lua_State *L) |
UGLuaPrint. Redirects LUA prints to UG_LOG. More... | |
int | UGLuaWrite (lua_State *L) |
UGLuaWrite. Redirects LUA prints to UG_LOG without adding newline at the end. More... | |
void | UpdateDepth () |
static void | UpdateScriptAfterRegistryChange (ug::bridge::Registry *pReg) |
Variables | |
static bool | bDebugging = false |
static bool | bProfiling = false |
static std::map< std::string, std::map< int, bool > > | breakpoints |
int | curHookMask = 0 |
static int | currentDepth = -1 |
static int | debugMode = DEBUG_CONTINUE |
static ug::bridge::Registry * | g_pRegistry = NULL |
static int | lastline = -1 |
static std::string | lastsource |
static debug_return(* | pDebugShell )() = NULL |
stack< string > | stkPathes |
static lua_State * | theLuaState = NULL |
void ug::script::AddBreakpoint | ( | const char * | source, |
int | line | ||
) |
References bDebugging, breakpoints, CheckHook(), GetAbsoluteUGScriptFilename(), pDebugShell, s, boost::source(), and UG_LOG.
Referenced by RegisterLuaDebug().
void ug::script::breakpoint | ( | ) |
References bDebugging, breakpoints, CheckHook(), DEBUG_CONTINUE, DEBUG_EXIT, DEBUG_FINISH, DEBUG_NEXT, DEBUG_STEP, debugMode, pDebugShell, UG_LOG, and ug::UGForceExit().
Referenced by breakpoint_in_script(), and luaDebug().
void ug::script::breakpoint_in_script | ( | ) |
References breakpoint(), currentDepth, GetDefaultLuaState(), getDepth(), lastline, and lastsource.
Referenced by RegisterLuaDebug().
void ug::script::CheckHook | ( | ) |
References bDebugging, bProfiling, curHookMask, GetDefaultLuaState(), and LuaCallHook().
Referenced by AddBreakpoint(), breakpoint(), DebugHold(), LuaCallHook(), and ProfileLUA().
UG_API void ug::script::DebugBacktrace | ( | int | fromLevel | ) |
lists the function stack in lua
References ug::bridge::LuaStackTrace().
Referenced by ug::bridge::DebugShell(), and RegisterLuaDebug().
UG_API void ug::script::DebugDown | ( | ) |
move down function stack
References currentDepth, getDepth(), UG_LOG, and UpdateDepth().
Referenced by ug::bridge::DebugShell().
UG_API void ug::script::DebugHold | ( | ) |
References bDebugging, CheckHook(), DEBUG_STEP, debugMode, and lastsource.
UG_API void ug::script::DebugList | ( | ) |
lists the current line in the script
References currentDepth, GetDefaultLuaState(), getDepth(), ug::GetFileLines(), lastline, lastsource, and UG_LOG.
Referenced by ug::bridge::DebugShell().
UG_API void ug::script::DebugUp | ( | ) |
move down function stack
References currentDepth, UG_LOG, and UpdateDepth().
Referenced by ug::bridge::DebugShell().
UG_API void ug::script::FinalizeLUADebug | ( | ) |
Free all memory associated with lua_debug.
References breakpoints, and lastsource.
Referenced by ReleaseDefaultLuaState().
UG_API bool ug::script::GetAbsoluteUGScriptFilename | ( | const std::string & | filename, |
std::string & | absoluteFilename | ||
) |
searches for the filename
filename | in: relative filename to paths above. out: absolute filename (if found) |
bool ug::script::GetAbsoluteUGScriptFilename | ( | const string & | filename, |
string & | absoluteFilename | ||
) |
say UG4_ROOT is the root path of ug4 (containing ugbase, apps, scripts and so on) This function will search a file (in this order) 1.) relative to the current script path. 2.) as a normal, i.e. absolute or relative to the working directory, filename 3.) relative to SCRIPT_PATH (normally UG4_ROOT/scripts) 4.) relative to APPS_PATH (normally UG4_ROOT/apps) 5.) relative to UG4_ROOT
filename | |
absoluteFilename |
References ug::APPS_PATH, GetNormalFilename(), PROFILE_FUNC, ug::ROOT_PATH, and ug::SCRIPT_PATH.
Referenced by AddBreakpoint(), and LoadUGScript().
std::string ug::script::GetAbsoluteUGScriptFilenamePaths | ( | ) |
References ug::APPS_PATH, ug::ROOT_PATH, and ug::SCRIPT_PATH.
Referenced by LoadUGScript().
returns the default lua state
When called for the first time, or after ReleaseDefaultLuaState, a new state is created and the methods and classes in ugs default registry (ug::bridge::GetUGRegistry) are registered. Furthermore a callback is registered, which registers new methods whenever Registry::registry_changed() is called on the default registry.
References ug::bridge::Registry::add_callback(), ug::bridge::lua::CreateBindings_LUA(), g_pRegistry, ug::bridge::GetUGRegistry(), PROFILE_BEGIN, theLuaState, UG_ASSERT, UGAlgebraCompiled(), UGDimCompiled(), UGGetClassGroup(), UGGetClassName(), UGGetMetatable(), UGIsBaseClass(), and UpdateScriptAfterRegistryChange().
Referenced by breakpoint_in_script(), ug::LuaUserData< TData, dim, TRet >::check_callback_returns(), CheckHook(), ug::CheckLuaCallbackName(), ug::bridge::ClassInstantiations(), ug::LUAParserClass::createVM(), DebugList(), ug::bridge::lua::GetColonWarning(), getDepth(), ug::bridge::GetGlobalFunctionInfo(), ug::bridge::GetGlobalsCompletitions(), ug::bridge::GetLuaGlobals(), ug::bridge::GetLUAScriptFunctionDefined(), ug::bridge::GetMemberFunctionCompletitions(), ug::bridge::GetMemberFunctionInfo(), ug::bridge::GetNamespaceCompletitions(), ug::LUAParserClass::getVar(), ug::LuaFunction< TData, TDataIn >::LuaFunction(), ug::bridge::LuaList_classInstantiations(), ug::bridge::LuaList_luaObjects(), ug::bridge::LuaList_scriptFunctions(), ug::bridge::LuaStackTrace(), ug::bridge::LuaStackTraceString(), ug::LuaUserData< TData, dim, TRet >::LuaUserData(), ug::LuaUserFunction< TData, dim, TDataIn >::LuaUserFunction(), ug::LuaUserNumberNumberFunction::LuaUserNumberNumberFunction(), ug::bridge::LuaWrite(), ug::bridge::LuaWriteCout(), ug::LUAParserClass::parse_luaFunction(), ug::LUAParserClass::parse_luaFunction_StackTop(), ParseAndExecuteBuffer(), ug::bridge::SetLuaNamespace(), ug::bridge::SetLuaNamespaceInTable(), ug_init_luashell(), ug::bridge::UGTypeInfo(), UpdateDepth(), and UpdateScriptAfterRegistryChange().
int ug::script::getDepth | ( | ) |
References GetDefaultLuaState().
Referenced by breakpoint_in_script(), DebugDown(), DebugList(), luaDebug(), and UpdateDepth().
bool ug::script::GetNormalFilename | ( | const string & | filename, |
string & | returnedFilename | ||
) |
filename | |
returnedFilename |
References ug::FileExists().
Referenced by GetAbsoluteUGScriptFilename().
|
static |
References s.
Referenced by UGLuaErrLog(), UGLuaPrint(), UGLuaPrintAllProcs(), and UGLuaWrite().
bool ug::script::IsLUADebug | ( | ) |
References bProfiling.
Referenced by lua_backtrace().
bool ug::script::LoadUGScript | ( | const char * | _filename, |
bool | bDistributedLoad, | ||
bool | bThrowOnError | ||
) |
_filename | the 'relative' script name. |
bDistributedLoad | true if loading should be done in parallel |
bThrowOnError | true if errors should be thrown as UGError, else as return false |
References pcl::AllProcsTrue(), GetAbsoluteUGScriptFilename(), GetAbsoluteUGScriptFilenamePaths(), pcl::NumProcs(), pcl::ParallelReadFile(), ParseAndExecuteBuffer(), ug::PathFromFilename(), pcl::ProcRank(), PROFILE_FUNC, ug::ReadFile(), and UG_THROW.
Referenced by LoadUGScript_Parallel(), and LoadUGScript_Single().
UG_API bool ug::script::LoadUGScript | ( | const char * | filename, |
bool | bDistributed | ||
) |
loads and parses a file. Several paths are tried if the file is not found.
Throws an instance of LuaError, if a parse error occurs. This method first tries to load the file specified with filename relative to the path of the currently parsed file (if LoadUGScript is called from within a load-script). If this failed, the file is tried to be loaded with the raw specified filename. If this fails too, the method tries to load the file from ugs scripting directory.
Note that this method pushes the path of the currently parsed script to PathProvider when parsing starts, and pops it when parsing is done.
filename | The filename for the script to be loaded. may be relative to ug4/apps/ |
bDistributed | if true, loads the script on core 0 and distributes the script to all other cores via pcl::broadcast . Use this whenever possible when doing parallel work otherwise this routine can take a long time (ignored if UG_PARALLEL not defined) |
UG_API bool ug::script::LoadUGScript_Parallel | ( | const char * | filename | ) |
calls LoadUGScript with bDistributed=true
References LoadUGScript().
Referenced by RegisterDefaultLuaBridge(), and ugshell_main().
UG_API bool ug::script::LoadUGScript_Single | ( | const char * | filename | ) |
calls LoadUGScript with bDistributed=false . Avoid. (
References LoadUGScript().
Referenced by RegisterDefaultLuaBridge().
void ug::script::LuaCallHook | ( | lua_State * | L, |
lua_Debug * | ar | ||
) |
References bDebugging, bProfiling, CheckHook(), luaDebug(), ug::repeat(), boost::source(), sprintf(), UG_ASSERT, UG_LOG, and UG_THROW.
Referenced by CheckHook().
int ug::script::luaCallStackError | ( | lua_State * | L | ) |
error function to be used for lua_pcall
References ug::bridge::LuaStackTrace(), and UG_LOG.
Referenced by ParseAndExecuteBuffer().
void ug::script::luaDebug | ( | lua_State * | L, |
const char * | source, | ||
int | line | ||
) |
References breakpoint(), breakpoints, currentDepth, DEBUG_FINISH, DEBUG_NEXT, DEBUG_STEP, debugMode, getDepth(), lastline, lastsource, pDebugShell, and boost::source().
Referenced by LuaCallHook().
UG_API bool ug::script::ParseAndExecuteBuffer | ( | const char * | buffer, |
const char * | bufferName = "buffer" |
||
) |
Parses the content of buffer and executes it in the default lua state
buffer | the buffer to be executed |
bufferName | name of the buffer (for error messages) |
References GetDefaultLuaState(), luaCallStackError(), PROFILE_BEGIN, PROFILE_END_, and PROFILE_FUNC.
Referenced by ug::bridge::DebugShell(), LoadUGScript(), ug::bridge::RunShell(), SetLuaDebug(), SetLuaDebugIDs(), and ugshell_main().
void ug::script::PrintBreakpoints | ( | ) |
References breakpoints, and UG_LOG.
Referenced by RegisterLuaDebug().
UG_API void ug::script::ProfileLUA | ( | bool | b | ) |
References bProfiling, CheckHook(), and UG_LOG.
Referenced by RegisterLuaDebug().
UG_API void ug::script::RegisterDefaultLuaBridge | ( | ug::bridge::Registry * | reg, |
std::string | grp | ||
) |
registers lua only functionality at the registry
References ug::bridge::Registry::add_function(), ug::bridge::Registry::functionname_registered(), LoadUGScript_Parallel(), LoadUGScript_Single(), ug::bridge::RegisterConverter(), ug::bridge::RegisterInfoCommands(), RegisterLuaDebug(), and ug::bridge::RegisterLuaUserData().
Referenced by ug_check_registry().
UG_API bool ug::script::RegisterLuaDebug | ( | ug::bridge::Registry & | reg | ) |
Register debug/profile functions
reg |
References ug::bridge::Registry::add_function(), AddBreakpoint(), breakpoint_in_script(), DebugBacktrace(), PrintBreakpoints(), and ProfileLUA().
Referenced by RegisterDefaultLuaBridge().
register functions like print and write directly to LUA (not using the ug registry)
References UGLuaErrLog(), UGLuaPrint(), UGLuaPrintAllProcs(), and UGLuaWrite().
Referenced by ug_init_luashell().
UG_API void ug::script::ReleaseDefaultLuaState | ( | ) |
calls lua_close, which calls delete for all lua objects
Releases the lua-state returned by GetDefaultLuaState().
This method is useful, if you want to restart scripting from scratch.
References FinalizeLUADebug(), and theLuaState.
UG_API int ug::script::SetDebugShell | ( | debug_return(*)() | s | ) |
function called when a breakpoint is reached
s | debug shell function |
References pDebugShell, and s.
Referenced by ug::bridge::InitShell().
void ug::script::SetLuaDebug | ( | lua_State * | L, |
string | id | ||
) |
References name, p, and ParseAndExecuteBuffer().
Referenced by SetLuaDebugIDs().
References ParseAndExecuteBuffer(), s, and SetLuaDebug().
Referenced by ug_init_luashell().
create ugargc and ugargv in lua we want to forward argc and argv to the lua-environment. we'll create a table for that.
L | the LUA state |
argc | the commandline argc |
argv | the commandline argv |
Referenced by ug_init_luashell().
Returns classgroup of a userdata as string.
References ug::bridge::Registry::get_class(), ug::bridge::GetUGRegistry(), ug::bridge::IExportedClass::group(), ug::bridge::ClassNameNode::name(), and UG_THROW.
Referenced by GetDefaultLuaState().
Returns type of a userdata as string.
References ug::bridge::ClassNameNode::name(), and UG_THROW.
Referenced by GetDefaultLuaState().
Returns if a class contains a base class.
References ug::bridge::ClassNameTreeContains(), ug::bridge::ClassNameNode::empty(), and UG_THROW.
Referenced by GetDefaultLuaState().
int ug::script::UGLuaErrLog | ( | lua_State * | L | ) |
UGLuaErrLog.
References ug::LogAssistant::flush(), ug::GetLogAssistant(), GetToStringFromStack(), and UG_ERR_LOG.
Referenced by RegisterStdLUAFunctions().
UGLuaPrint. Redirects LUA prints to UG_LOG.
References GetToStringFromStack(), and UG_LOG.
Referenced by RegisterStdLUAFunctions().
int ug::script::UGLuaPrintAllProcs | ( | lua_State * | L | ) |
UGLuaPrint. Redirects LUA prints to UG_LOG.
UGLuaPrintAllProcs. Redirects LUA prints to UG_LOG_ALL_PROCS.
References GetToStringFromStack(), and UG_LOG_ALL_PROCS.
Referenced by RegisterStdLUAFunctions().
UGLuaWrite. Redirects LUA prints to UG_LOG without adding newline at the end.
UGLuaWrite. prints LUA output to UG_LOG without adding std::endl automatically.
References ug::LogAssistant::flush(), ug::GetLogAssistant(), GetToStringFromStack(), and UG_LOG.
Referenced by RegisterStdLUAFunctions().
void ug::script::UpdateDepth | ( | ) |
References currentDepth, GetDefaultLuaState(), getDepth(), ug::GetFileLine(), lastline, lastsource, and UG_LOG.
Referenced by DebugDown(), and DebugUp().
|
static |
References ug::bridge::lua::CreateBindings_LUA(), g_pRegistry, GetDefaultLuaState(), PROFILE_FUNC, and UG_ASSERT.
Referenced by GetDefaultLuaState().
|
static |
Referenced by AddBreakpoint(), breakpoint(), CheckHook(), DebugHold(), and LuaCallHook().
|
static |
Referenced by CheckHook(), IsLUADebug(), LuaCallHook(), and ProfileLUA().
|
static |
Referenced by AddBreakpoint(), breakpoint(), FinalizeLUADebug(), luaDebug(), and PrintBreakpoints().
int ug::script::curHookMask = 0 |
Referenced by CheckHook().
|
static |
Referenced by breakpoint_in_script(), DebugDown(), DebugList(), DebugUp(), luaDebug(), and UpdateDepth().
|
static |
Referenced by breakpoint(), DebugHold(), and luaDebug().
|
static |
Referenced by GetDefaultLuaState(), and UpdateScriptAfterRegistryChange().
|
static |
Referenced by breakpoint_in_script(), DebugList(), luaDebug(), and UpdateDepth().
|
static |
Referenced by breakpoint_in_script(), DebugHold(), DebugList(), FinalizeLUADebug(), luaDebug(), and UpdateDepth().
|
static |
Referenced by AddBreakpoint(), breakpoint(), luaDebug(), and SetDebugShell().
|
extern |
|
static |
Referenced by GetDefaultLuaState(), and ReleaseDefaultLuaState().