mirror of
https://github.com/edubart/otclient.git
synced 2025-10-22 15:25:54 +02:00
reorganize all constants and place them into namespaces
This commit is contained in:
@@ -33,21 +33,21 @@ void LuaException::generateLuaErrorMessage(const std::string& error, int traceLe
|
||||
{
|
||||
// append trace level to error message
|
||||
if(traceLevel >= 0)
|
||||
m_what = fw::mkstr("LUA ERROR: ", g_lua.traceback(error, traceLevel));
|
||||
m_what = Fw::mkstr("LUA ERROR: ", g_lua.traceback(error, traceLevel));
|
||||
else
|
||||
m_what = fw::mkstr("LUA ERROR: ", error);
|
||||
m_what = Fw::mkstr("LUA ERROR: ", error);
|
||||
}
|
||||
|
||||
LuaBadNumberOfArgumentsException::LuaBadNumberOfArgumentsException(int expected, int got)
|
||||
{
|
||||
std::string error = "attempt to call a function with wrong number of arguments";
|
||||
if(expected >= 0 && got >= 0)
|
||||
error = fw::mkstr(error, " (expected ", expected, ", but got ", got, ")");
|
||||
error = Fw::mkstr(error, " (expected ", expected, ", but got ", got, ")");
|
||||
generateLuaErrorMessage(error, 1);
|
||||
}
|
||||
|
||||
LuaBadValueCastException::LuaBadValueCastException(const std::string& luaTypeName, const std::string& cppTypeName)
|
||||
{
|
||||
std::string error = fw::mkstr("attempt to cast a '", luaTypeName, "' lua value to '", cppTypeName, "'");
|
||||
std::string error = Fw::mkstr("attempt to cast a '", luaTypeName, "' lua value to '", cppTypeName, "'");
|
||||
generateLuaErrorMessage(error, 0);
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ void LuaInterface::init()
|
||||
createLuaState();
|
||||
|
||||
// check if demangle_type is working as expected
|
||||
assert(fw::demangle_type<LuaObject>() == "LuaObject");
|
||||
assert(Fw::demangleType<LuaObject>() == "LuaObject");
|
||||
|
||||
// register LuaObject, the base of all other objects
|
||||
registerClass<LuaObject>();
|
||||
@@ -147,12 +147,12 @@ void LuaInterface::registerClassMemberField(const std::string& className,
|
||||
|
||||
if(getFunction) {
|
||||
pushCppFunction(getFunction);
|
||||
setField(fw::mkstr("get_", field));
|
||||
setField(Fw::mkstr("get_", field));
|
||||
}
|
||||
|
||||
if(setFunction) {
|
||||
pushCppFunction(setFunction);
|
||||
setField(fw::mkstr("set_", field));
|
||||
setField(Fw::mkstr("set_", field));
|
||||
}
|
||||
|
||||
pop();
|
||||
@@ -295,7 +295,7 @@ void LuaInterface::loadFunction(const std::string& buffer, const std::string& so
|
||||
// gets the function contained in that buffer
|
||||
if(boost::starts_with(buffer, "function")) {
|
||||
// evaluate the function
|
||||
std::string buf = fw::mkstr("__func = ", buffer);
|
||||
std::string buf = Fw::mkstr("__func = ", buffer);
|
||||
loadBuffer(buf, source);
|
||||
safeCall();
|
||||
|
||||
@@ -317,7 +317,7 @@ void LuaInterface::evaluateExpression(const std::string& expression, const std::
|
||||
{
|
||||
// evaluates the expression
|
||||
if(!expression.empty()) {
|
||||
std::string buffer = fw::mkstr("__exp = (", expression, ")");
|
||||
std::string buffer = Fw::mkstr("__exp = (", expression, ")");
|
||||
loadBuffer(buffer, source);
|
||||
safeCall();
|
||||
|
||||
@@ -917,7 +917,7 @@ void LuaInterface::pushObject(const LuaObjectPtr& obj)
|
||||
new(newUserdata(sizeof(LuaObjectPtr))) LuaObjectPtr(obj);
|
||||
|
||||
// set the userdata metatable
|
||||
getGlobal(fw::mkstr(obj->getLuaObjectName(), "_mt"));
|
||||
getGlobal(Fw::mkstr(obj->getLuaObjectName(), "_mt"));
|
||||
assert(!isNil());
|
||||
setMetatable();
|
||||
}
|
||||
|
@@ -63,24 +63,24 @@ public:
|
||||
// register shortcuts using templates
|
||||
template<class C, class B = LuaObject>
|
||||
void registerClass() {
|
||||
registerClass(fw::demangle_type<C>(), fw::demangle_type<B>());
|
||||
registerClass(Fw::demangleType<C>(), Fw::demangleType<B>());
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void registerClassStaticFunction(const std::string& functionName, const LuaCppFunction& function) {
|
||||
registerClassStaticFunction(fw::demangle_type<C>(), functionName, function);
|
||||
registerClassStaticFunction(Fw::demangleType<C>(), functionName, function);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void registerClassMemberFunction(const std::string& functionName, const LuaCppFunction& function) {
|
||||
registerClassMemberFunction(fw::demangle_type<C>(), functionName, function);
|
||||
registerClassMemberFunction(Fw::demangleType<C>(), functionName, function);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void registerClassMemberField(const std::string& field,
|
||||
const LuaCppFunction& getFunction,
|
||||
const LuaCppFunction& setFunction) {
|
||||
registerClassMemberField(fw::demangle_type<C>(), field, getFunction, setFunction);
|
||||
registerClassMemberField(Fw::demangleType<C>(), field, getFunction, setFunction);
|
||||
}
|
||||
|
||||
// methods for binding functions
|
||||
@@ -343,7 +343,7 @@ template<class T>
|
||||
T LuaInterface::castValue(int index) {
|
||||
T o;
|
||||
if(!luavalue_cast(index, o))
|
||||
throw LuaBadValueCastException(typeName(index), fw::demangle_type<T>());
|
||||
throw LuaBadValueCastException(typeName(index), Fw::demangleType<T>());
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,7 @@ public:
|
||||
/// Returns the class name used in Lua
|
||||
virtual std::string getLuaObjectName() const {
|
||||
// this could later be cached for more performance
|
||||
return fw::demangle_name(typeid(*this).name());
|
||||
return Fw::demangleName(typeid(*this).name());
|
||||
}
|
||||
|
||||
LuaObjectPtr asLuaObject() { return shared_from_this(); }
|
||||
|
@@ -130,9 +130,9 @@ bool luavalue_cast(int index, Color& color)
|
||||
color.setAlpha(g_lua.popInteger());
|
||||
return true;
|
||||
} else if(g_lua.isString()) {
|
||||
return fw::cast(g_lua.toString(index), color);
|
||||
return Fw::cast(g_lua.toString(index), color);
|
||||
} else if(g_lua.isNil()) {
|
||||
color = Color::white;
|
||||
color = Fw::white;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -164,7 +164,7 @@ bool luavalue_cast(int index, Rect& rect)
|
||||
g_lua.getField("height", index);
|
||||
rect.setHeight(g_lua.popInteger());
|
||||
} else if(g_lua.isString()) {
|
||||
return fw::cast(g_lua.toString(index), rect);
|
||||
return Fw::cast(g_lua.toString(index), rect);
|
||||
} else if(g_lua.isNil()) {
|
||||
rect = Rect();
|
||||
return true;
|
||||
@@ -191,7 +191,7 @@ bool luavalue_cast(int index, Point& point)
|
||||
point.y = g_lua.popInteger();
|
||||
return true;
|
||||
} else if(g_lua.isString()) {
|
||||
return fw::cast(g_lua.toString(index), point);
|
||||
return Fw::cast(g_lua.toString(index), point);
|
||||
} else if(g_lua.isNil()) {
|
||||
point = Point();
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user