ug4
|
Classes | |
struct | ConstSmartUserDataWrapper |
struct | LuaParsing |
struct | LuaParsing< bool > |
struct | LuaParsing< const char * > |
struct | LuaParsing< const std::string & > |
struct | LuaParsing< const void * > |
struct | LuaParsing< ConstSmartPtr< void > > |
struct | LuaParsing< double > |
struct | LuaParsing< float > |
struct | LuaParsing< int > |
struct | LuaParsing< size_t > |
struct | LuaParsing< SmartPtr< void > > |
struct | LuaParsing< std::string > |
struct | LuaParsing< void * > |
struct | RawUserDataWrapper |
struct | SmartUserDataWrapper |
struct | UserDataWrapper |
Enumerations | |
enum | UserDataWrapperTypes { RAW_POINTER = 1 , SMART_POINTER = 1 << 1 , IS_CONST = 1 << 2 } |
Functions | |
bool | CreateBindings_LUA (lua_State *L, Registry ®) |
creates bindings for ug_interface and a given lua-state. More... | |
static int | ExecuteMethod (lua_State *L, const ExportedMethodGroup *methodGrp, UserDataWrapper *self, const ClassNameNode *classNameNode, bool errorOutput) |
void | GetBestMatchingMember (const char *classname, const char *name, std::string &minname, int &mind) |
void | GetBestMatchingMember (const IExportedClass *c, const char *name, std::string &minname, int &mind) |
std::string | GetColonWarning (std::string name) |
static string | GetLuaParametersString (lua_State *L, int offsetToFirstParam=0) |
returns a String describing the parameters on the lua stack ex. "GlobalMultiGridRefiner*, LuaUserNumber2d*, number, string" More... | |
string | GetNilWarning (lua_State *L, int offsetToFirstParam) |
static string | GetTypeMismatchString (const ParameterInfo ¶msTemplate, lua_State *L, int offsetToFirstParam, int badParamOneBased) |
static int | LuaConstructor (lua_State *L, IExportedClass *c, const char *groupname=nullptr) |
static int | LuaProxyConstructor (lua_State *L) |
static int | LuaProxyDelete (lua_State *L) |
static int | LuaProxyFunction (lua_State *L) |
static int | LuaProxyGroupConstructor (lua_State *L) |
static int | LuaProxyMethod (lua_State *L) |
static int | LuaProxyRelease (lua_State *L) |
static int | LuaToStringDefault (lua_State *L) |
static int | MetatableIndexer (lua_State *L) |
std::string | ParameterStackString (ParameterStack &s) |
void | PrintLUACallStack () |
string | UGErrorTraceback (UGError &err) |
SmartUserDataWrapper * | CreateNewUserData (lua_State *L, const SmartPtr< void > &ptr, const char *metatableName) |
creates a new UserDataWrapper and associates it with ptr in luas registry More... | |
ConstSmartUserDataWrapper * | CreateNewUserData (lua_State *L, const ConstSmartPtr< void > &ptr, const char *metatableName) |
creates a new UserDataWrapper and associates it with ptr in luas registry More... | |
RawUserDataWrapper * | CreateNewUserData (lua_State *L, void *ptr, const char *metatableName, void(*deleteFunc)(const void *), bool is_const) |
creates a new UserDataWrapper and associates it with ptr in luas registry More... | |
Variables | |
const bool | IMLPICIT_SMART_PTR_TO_PTR_CONVERSION = true |
creates bindings for ug_interface and a given lua-state.
Registers a meta-object for each class and class group found in the ug registry reg. Global functions are registered for all GlobalFunction-objects in the registry reg.
L | the Lua State |
reg | the ug registry |
If you use ug::script, this method will be invoked automatically.
References ug::bridge::IExportedClass::class_name_node(), ug::bridge::IExportedClass::class_names(), ug::bridge::Registry::get_class(), ug::bridge::Registry::get_class_group(), ug::bridge::IExportedClass::get_const_method_group(), ug::bridge::Registry::get_function_group(), ug::bridge::IExportedClass::get_method_group(), ug::bridge::IExportedClass::is_instantiable(), LuaProxyConstructor(), LuaProxyDelete(), LuaProxyFunction(), LuaProxyGroupConstructor(), LuaProxyMethod(), LuaProxyRelease(), LuaToStringDefault(), MetatableIndexer(), ug::bridge::ExportedMethodGroup::name(), ug::bridge::ExportedFunctionGroup::name(), ug::bridge::ClassGroupDesc::name(), ug::bridge::IExportedClass::name(), ug::bridge::Registry::num_class_groups(), ug::bridge::Registry::num_classes(), ug::bridge::IExportedClass::num_const_methods(), ug::bridge::Registry::num_functions(), and ug::bridge::IExportedClass::num_methods().
Referenced by ug::script::GetDefaultLuaState(), and ug::script::UpdateScriptAfterRegistryChange().
ConstSmartUserDataWrapper * ug::bridge::lua::CreateNewUserData | ( | lua_State * | L, |
const ConstSmartPtr< void > & | ptr, | ||
const char * | metatableName | ||
) |
creates a new UserDataWrapper and associates it with ptr in luas registry
Creates a new userdata in lua, which encapsulates the given pointer / smart-pointer. It then assigns the specified metatable to the userdata. When the function is done, the userdata is left on luas stack.
References IS_CONST, SMART_POINTER, ug::bridge::lua::ConstSmartUserDataWrapper::smartPtr, and ug::bridge::lua::UserDataWrapper::type.
SmartUserDataWrapper * ug::bridge::lua::CreateNewUserData | ( | lua_State * | L, |
const SmartPtr< void > & | ptr, | ||
const char * | metatableName | ||
) |
creates a new UserDataWrapper and associates it with ptr in luas registry
Creates a new userdata in lua, which encapsulates the given pointer / smart-pointer. It then assigns the specified metatable to the userdata. When the function is done, the userdata is left on luas stack.
References SMART_POINTER, ug::bridge::lua::SmartUserDataWrapper::smartPtr, and ug::bridge::lua::UserDataWrapper::type.
Referenced by ug::bridge::lua::LuaParsing< const void * >::push(), ug::bridge::lua::LuaParsing< ConstSmartPtr< void > >::push(), ug::bridge::lua::LuaParsing< SmartPtr< void > >::push(), and ug::bridge::lua::LuaParsing< void * >::push().
RawUserDataWrapper * ug::bridge::lua::CreateNewUserData | ( | lua_State * | L, |
void * | ptr, | ||
const char * | metatableName, | ||
void(*)(const void *) | deleteFunc, | ||
bool | is_const | ||
) |
creates a new UserDataWrapper and associates it with ptr in luas registry
Creates a new userdata in lua, which encapsulates the given pointer / smart-pointer. It then assigns the specified metatable to the userdata. When the function is done, the userdata is left on luas stack.
References ug::bridge::lua::RawUserDataWrapper::deleteFunc, IS_CONST, ug::bridge::lua::RawUserDataWrapper::obj, RAW_POINTER, and ug::bridge::lua::UserDataWrapper::type.
Referenced by LuaConstructor().
|
static |
This method is not called by lua, but a helper to LuaProxyMethod. It recursively calls itself until a matching overload was found.
L | |
methodGrp | |
self | |
classNameNode | |
errorOutput |
References ug::bridge::ClassNameNode::base_class(), ug::bridge::ExportedMethod::class_name(), ug::bridge::ExportedMethod::execute(), func(), ug::bridge::FunctionInfo(), ug::bridge::ExportedMethodGroup::get_overload(), GetTypeMismatchString(), ug::bridge::ExportedMethod::has_custom_return(), ug::bridge::LuaClassMethodInfo(), ug::bridge::LuaStackToParams(), ug::bridge::ExportedMethodGroup::name(), ug::bridge::ClassNameNode::name(), ug::bridge::ClassNameNode::num_base_classes(), ug::bridge::ExportedMethodGroup::num_overloads(), ParameterStackString(), ug::bridge::ExportedFunctionBase::params_in(), ug::bridge::ParamsToLuaStack(), UG_LOG, and UG_LUA_BINDINGS_CATCH.
Referenced by LuaProxyMethod().
void ug::bridge::lua::GetBestMatchingMember | ( | const char * | classname, |
const char * | name, | ||
std::string & | minname, | ||
int & | mind | ||
) |
References ug::bridge::Registry::get_class(), ug::bridge::GetUGRegistry(), and name.
Referenced by GetBestMatchingMember(), and MetatableIndexer().
void ug::bridge::lua::GetBestMatchingMember | ( | const IExportedClass * | c, |
const char * | name, | ||
std::string & | minname, | ||
int & | mind | ||
) |
This function is used if the user enters a member function wrong and returns the best guess what he means. Also searches in base classes.
c | (in) the class |
name | (in) the name of the member function we are searching |
minname | (out) the name of the closest match to name (in Levenshtein-Distance) |
mind | (out) number of edits needed from name -> minname |
References ug::bridge::IExportedClass::class_names(), ug::bridge::Registry::get_class(), ug::bridge::IExportedClass::get_const_method(), ug::bridge::IExportedClass::get_method(), GetBestMatchingMember(), ug::bridge::GetUGRegistry(), ug::LevenshteinDistance(), name, ug::bridge::ExportedFunctionBase::name(), ug::bridge::IExportedClass::num_const_methods(), and ug::bridge::IExportedClass::num_methods().
std::string ug::bridge::lua::GetColonWarning | ( | std::string | name | ) |
users sometimes use the . operator (like in myObject.the_method(parameter) ), which sometimes print very weird error messages. this function tries to catch some of those errors. NOTE: this function can NOT catch errors like approxSpace.print_statistic() ( note the wrong . )
name | the name of the function. will be used to search "."+name in the code. |
References errSymb, ug::script::GetDefaultLuaState(), ug::bridge::GetLuaLine(), and name.
Referenced by LuaProxyMethod().
|
static |
returns a String describing the parameters on the lua stack ex. "GlobalMultiGridRefiner*, LuaUserNumber2d*, number, string"
References ug::bridge::GetLuaTypeString().
Referenced by LuaConstructor(), LuaProxyFunction(), and LuaProxyMethod().
string ug::bridge::lua::GetNilWarning | ( | lua_State * | L, |
int | offsetToFirstParam | ||
) |
if one of the parameters is nil, this returns an error to warn the user about not initialised variables
L | the lua state |
offsetToFirstParam | offset to first param |
References errSymb.
Referenced by LuaConstructor(), LuaProxyFunction(), and LuaProxyMethod().
|
static |
paramsTempalte | |
L | |
offsetToFirstParam | |
badParamOneBased | : return value as in LuaStackParams |
References ug::bridge::GetLuaTypeString(), ParameterToString(), and ug::bridge::ParameterInfo::size().
Referenced by ExecuteMethod(), LuaConstructor(), and LuaProxyFunction().
|
static |
Helper function of LuaProxyConstructor and LuaProxyGroupConstructor
L | |
c | the class to create and object of |
groupname | if not nil, c is the default class of this group |
References ug::bridge::IExportedClass::construct_as_smart_pointer(), ug::bridge::ConstructorInfo(), ug::bridge::ExportedConstructor::create(), CreateNewUserData(), errSymb, ug::bridge::IExportedClass::get_constructor(), ug::bridge::IExportedClass::get_delete_function(), ug::bridge::GetLuaFileAndLine(), GetLuaParametersString(), GetNilWarning(), GetTypeMismatchString(), ug::bridge::LuaStackToParams(), ug::bridge::IExportedClass::name(), ug::bridge::IExportedClass::num_constructors(), ParameterStackString(), ug::bridge::ExportedConstructor::params_in(), PrintLUACallStack(), UG_LOG, UG_LUA_BINDINGS_CATCH, and UG_LUA_THROW_EMPTY.
Referenced by LuaProxyConstructor(), and LuaProxyGroupConstructor().
|
static |
creates a object of a class
L |
References LuaConstructor().
Referenced by CreateBindings_LUA().
|
static |
References ug::bridge::lua::RawUserDataWrapper::deleteFunc, ug::bridge::lua::RawUserDataWrapper::obj, and UG_LOG.
Referenced by CreateBindings_LUA().
|
static |
LuaProxyFunction handling calls to global functions. Note that not the best matching, but the first matching overload is chosen!
L |
References errSymb, func(), ug::bridge::FunctionInfo(), ug::bridge::ExportedFunctionGroup::get_overload(), ug::bridge::GetLuaFileAndLine(), GetLuaParametersString(), GetNilWarning(), GetTypeMismatchString(), ug::bridge::LuaStackToParams(), ug::bridge::ExportedFunctionGroup::name(), ug::bridge::ExportedFunctionGroup::num_overloads(), ParameterStackString(), ug::bridge::ParamsToLuaStack(), PrintLUACallStack(), UG_LOG, UG_LUA_BINDINGS_CATCH, UG_LUA_THROW, and UG_LUA_THROW_EMPTY.
Referenced by CreateBindings_LUA().
|
static |
creates the class which is set as default class for the specified group. we assume that the first upvalue is a ClassGroupDesc*
L |
References ug::bridge::ClassGroupDesc::empty(), errSymb, ug::bridge::ClassGroupDesc::get_default_class(), ug::bridge::GetLuaFileAndLine(), LuaConstructor(), ug::bridge::ClassGroupDesc::name(), and UG_LOG.
Referenced by CreateBindings_LUA().
|
static |
member methods of classes are handled here
L | the lua State |
References errSymb, ExecuteMethod(), ug::bridge::ExportedMethodGroup::get_overload(), GetColonWarning(), ug::bridge::GetLuaFileAndLine(), GetLuaParametersString(), GetNilWarning(), ug::bridge::LuaClassMethodInfo(), ug::bridge::ExportedMethodGroup::name(), ug::bridge::ClassNameNode::name(), PrintLUACallStack(), UG_LOG, and UG_LUA_THROW_EMPTY.
Referenced by CreateBindings_LUA().
|
static |
Referenced by CreateBindings_LUA().
|
static |
a default __tostring method which shows classname: <adress> __tostring is used in all print(object) and tostring(object) calls in LUA
L |
References ug::bridge::IExportedClass::name(), ug::bridge::ParamsToLuaStack(), ug::bridge::ParameterStack::push(), and sprintf().
Referenced by CreateBindings_LUA().
|
static |
std::string ug::bridge::lua::ParameterStackString | ( | ParameterStack & | s | ) |
References boost::get(), and s.
Referenced by ExecuteMethod(), LuaConstructor(), and LuaProxyFunction().
void ug::bridge::lua::PrintLUACallStack | ( | ) |
prints the LUA Call Stack, i.e. the call stack of functions calls in LUA up to this point, files and filelines.
References ug::bridge::LuaStackTraceString(), s, and UG_LOG.
Referenced by LuaConstructor(), LuaProxyFunction(), and LuaProxyMethod().
string ug::bridge::lua::UGErrorTraceback | ( | UGError & | err | ) |
err |
References errSymb, ug::UGError::get_file(), ug::UGError::get_line(), ug::UGError::get_msg(), ug::UGError::num_msg(), and ug::SnipStringFront().
const bool ug::bridge::lua::IMLPICIT_SMART_PTR_TO_PTR_CONVERSION = true |