Lua binder compability changes

* A lot of changes in lua binder to compile with clang's libc++
* Add more portability to luabinder
* Remove const keyword from bound lua functions
* Deprecate std::bind usage with luabinder replace its usage with registerSingletonClass/bindSingletonFunction for binding singleton classes
* Fix a bug in lua binder where calling functions with bil object would make the client crash
* More fixes to compile with clang
This commit is contained in:
Eduardo Bart 2012-06-17 12:21:46 -03:00
parent 10b33c6124
commit ad04043a88
17 changed files with 368 additions and 397 deletions

1
TODO
View File

@ -76,4 +76,3 @@ terminate rework of ui events propagation (for Key events)
* lua engine * lua engine
make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size) make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size)
review usage of x,y/width,height in lua instead of point/size review usage of x,y/width,height in lua instead of point/size
calling UIWidget.getMarginTop(nil) makes client crashes

View File

@ -77,9 +77,9 @@ public:
return false; return false;
} }
int ticks() const { return m_ticks; } int ticks() { return m_ticks; }
int reamaningTicks() const { return m_ticks - g_clock.millis(); } int reamaningTicks() { return m_ticks - g_clock.millis(); }
int delay() const { return m_delay; } int delay() { return m_delay; }
int cyclesExecuted() { return m_cyclesExecuted; } int cyclesExecuted() { return m_cyclesExecuted; }
int maxCycles() { return m_maxCycles; } int maxCycles() { return m_maxCycles; }
@ -91,7 +91,7 @@ private:
}; };
struct lessScheduledEvent : std::binary_function<ScheduledEventPtr, ScheduledEventPtr&, bool> { struct lessScheduledEvent : std::binary_function<ScheduledEventPtr, ScheduledEventPtr&, bool> {
bool operator()(const ScheduledEventPtr& a, const ScheduledEventPtr& b) const { bool operator()(const ScheduledEventPtr& a, const ScheduledEventPtr& b) {
return b->ticks() < a->ticks(); return b->ticks() < a->ticks();
} }
}; };

View File

@ -160,7 +160,7 @@ void BitmapFont::calculateDrawTextCoords(CoordsBuffer& coordsBuffer, const std::
const std::vector<Point>& BitmapFont::calculateGlyphsPositions(const std::string& text, const std::vector<Point>& BitmapFont::calculateGlyphsPositions(const std::string& text,
Fw::AlignmentFlag align, Fw::AlignmentFlag align,
Size *textBoxSize) const Size *textBoxSize)
{ {
// for performance reasons we use statics vectors that are allocated on demand // for performance reasons we use statics vectors that are allocated on demand
static std::vector<Point> glyphsPositions(1); static std::vector<Point> glyphsPositions(1);

View File

@ -47,20 +47,20 @@ public:
/// Calculate glyphs positions to use on render, also calculates textBoxSize if wanted /// Calculate glyphs positions to use on render, also calculates textBoxSize if wanted
const std::vector<Point>& calculateGlyphsPositions(const std::string& text, const std::vector<Point>& calculateGlyphsPositions(const std::string& text,
Fw::AlignmentFlag align = Fw::AlignTopLeft, Fw::AlignmentFlag align = Fw::AlignTopLeft,
Size* textBoxSize = NULL) const; Size* textBoxSize = NULL);
/// Simulate render and calculate text size /// Simulate render and calculate text size
Size calculateTextRectSize(const std::string& text); Size calculateTextRectSize(const std::string& text);
std::string wrapText(const std::string& text, int maxWidth); std::string wrapText(const std::string& text, int maxWidth);
std::string getName() const { return m_name; } std::string getName() { return m_name; }
int getGlyphHeight() const { return m_glyphHeight; } int getGlyphHeight() { return m_glyphHeight; }
const Rect* getGlyphsTextureCoords() const { return m_glyphsTextureCoords; } const Rect* getGlyphsTextureCoords() { return m_glyphsTextureCoords; }
const Size* getGlyphsSize() const { return m_glyphsSize; } const Size* getGlyphsSize() { return m_glyphsSize; }
const TexturePtr& getTexture() const { return m_texture; } const TexturePtr& getTexture() { return m_texture; }
int getYOffset() const { return m_yOffset; } int getYOffset() { return m_yOffset; }
Size getGlyphSpacing() const { return m_glyphSpacing; } Size getGlyphSpacing() { return m_glyphSpacing; }
private: private:
/// Calculates each font character by inspecting font bitmap /// Calculates each font character by inspecting font bitmap

View File

@ -67,10 +67,10 @@ public:
void updateCaches(); void updateCaches();
bool isHardwareCached() { return m_hardwareCached; } bool isHardwareCached() { return m_hardwareCached; }
float *getVertexArray() const { return m_vertexArray.vertices(); } float *getVertexArray() { return m_vertexArray.vertices(); }
float *getTextureCoordArray() const { return m_textureCoordArray.vertices(); } float *getTextureCoordArray() { return m_textureCoordArray.vertices(); }
int getVertexCount() const { return m_vertexArray.vertexCount(); } int getVertexCount() { return m_vertexArray.vertexCount(); }
int getTextureCoordCount() const { return m_textureCoordArray.vertexCount(); } int getTextureCoordCount() { return m_textureCoordArray.vertexCount(); }
HardwareBuffer *getHardwareVertexArray() { return m_hardwareVertexArray; } HardwareBuffer *getHardwareVertexArray() { return m_hardwareVertexArray; }
HardwareBuffer *getHardwareTextureCoordArray() { return m_hardwareTextureCoordArray; } HardwareBuffer *getHardwareTextureCoordArray() { return m_hardwareTextureCoordArray; }

View File

@ -48,14 +48,14 @@ void Application::registerLuaFunctions()
g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return stdext::to_string(v); }); g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return stdext::to_string(v); });
g_lua.bindGlobalFunction("iptostring", [](int v) { return stdext::ip_to_string(v); }); g_lua.bindGlobalFunction("iptostring", [](int v) { return stdext::ip_to_string(v); });
g_lua.registerStaticClass("g_crypt"); g_lua.registerSingletonClass("g_crypt");
g_lua.bindClassStaticFunction("g_crypt", "encrypt", Crypt::encrypt); g_lua.bindClassStaticFunction("g_crypt", "encrypt", Crypt::encrypt);
g_lua.bindClassStaticFunction("g_crypt", "decrypt", Crypt::decrypt); g_lua.bindClassStaticFunction("g_crypt", "decrypt", Crypt::decrypt);
g_lua.registerStaticClass("g_clock"); g_lua.registerSingletonClass("g_clock");
g_lua.bindClassStaticFunction("g_clock", "micros", std::bind(&Clock::micros, &g_clock)); g_lua.bindSingletonFunction("g_clock", "micros", &Clock::micros, &g_clock);
g_lua.bindClassStaticFunction("g_clock", "millis", std::bind(&Clock::millis, &g_clock)); g_lua.bindSingletonFunction("g_clock", "millis", &Clock::millis, &g_clock);
g_lua.bindClassStaticFunction("g_clock", "seconds", std::bind(&Clock::seconds, &g_clock)); g_lua.bindSingletonFunction("g_clock", "seconds", &Clock::seconds, &g_clock);
// Event // Event
g_lua.registerClass<Event>(); g_lua.registerClass<Event>();
@ -478,151 +478,151 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<PainterShaderProgram>("addMultiTexture", &PainterShaderProgram::addMultiTexture); g_lua.bindClassMemberFunction<PainterShaderProgram>("addMultiTexture", &PainterShaderProgram::addMultiTexture);
// Application // Application
g_lua.registerStaticClass("g_app"); g_lua.registerSingletonClass("g_app");
g_lua.bindClassStaticFunction("g_app", "exit", std::bind(&Application::exit, g_app)); g_lua.bindSingletonFunction("g_app", "exit", &Application::exit, g_app);
g_lua.bindClassStaticFunction("g_app", "setForegroundPaneMaxFps", std::bind(&Application::setForegroundPaneMaxFps, g_app, std::placeholders::_1)); g_lua.bindSingletonFunction("g_app", "setForegroundPaneMaxFps", &Application::setForegroundPaneMaxFps, g_app);
g_lua.bindClassStaticFunction("g_app", "setBackgroundPaneMaxFps", std::bind(&Application::setBackgroundPaneMaxFps, g_app, std::placeholders::_1)); g_lua.bindSingletonFunction("g_app", "setBackgroundPaneMaxFps", &Application::setBackgroundPaneMaxFps, g_app);
g_lua.bindClassStaticFunction("g_app", "isRunning", std::bind(&Application::isRunning, g_app)); g_lua.bindSingletonFunction("g_app", "isRunning", &Application::isRunning, g_app);
g_lua.bindClassStaticFunction("g_app", "isStopping", std::bind(&Application::isStopping, g_app)); g_lua.bindSingletonFunction("g_app", "isStopping", &Application::isStopping, g_app);
g_lua.bindClassStaticFunction("g_app", "isOnInputEvent", std::bind(&Application::isOnInputEvent, g_app)); g_lua.bindSingletonFunction("g_app", "isOnInputEvent", &Application::isOnInputEvent, g_app);
g_lua.bindClassStaticFunction("g_app", "getName", std::bind(&Application::getName, g_app)); g_lua.bindSingletonFunction("g_app", "getName", &Application::getName, g_app);
g_lua.bindClassStaticFunction("g_app", "getVersion", std::bind(&Application::getVersion, g_app)); g_lua.bindSingletonFunction("g_app", "getVersion", &Application::getVersion, g_app);
g_lua.bindClassStaticFunction("g_app", "getForegroundPaneFps", std::bind(&Application::getForegroundPaneFps, g_app)); g_lua.bindSingletonFunction("g_app", "getForegroundPaneFps", &Application::getForegroundPaneFps, g_app);
g_lua.bindClassStaticFunction("g_app", "getBackgroundPaneFps", std::bind(&Application::getBackgroundPaneFps, g_app)); g_lua.bindSingletonFunction("g_app", "getBackgroundPaneFps", &Application::getBackgroundPaneFps, g_app);
g_lua.bindClassStaticFunction("g_app", "getForegroundPaneMaxFps", std::bind(&Application::getForegroundPaneMaxFps, g_app)); g_lua.bindSingletonFunction("g_app", "getForegroundPaneMaxFps", &Application::getForegroundPaneMaxFps, g_app);
g_lua.bindClassStaticFunction("g_app", "getBackgroundPaneMaxFps", std::bind(&Application::getBackgroundPaneMaxFps, g_app)); g_lua.bindSingletonFunction("g_app", "getBackgroundPaneMaxFps", &Application::getBackgroundPaneMaxFps, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildCompiler", std::bind(&Application::getBuildCompiler, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildCompiler", &Application::getBuildCompiler, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildDate", std::bind(&Application::getBuildDate, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildDate", &Application::getBuildDate, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildRevision", std::bind(&Application::getBuildRevision, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildRevision", &Application::getBuildRevision, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildType", std::bind(&Application::getBuildType, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildType", &Application::getBuildType, g_app);
g_lua.bindClassStaticFunction("g_app", "exit", std::bind(&Application::exit, g_app)); g_lua.bindSingletonFunction("g_app", "exit", &Application::exit, g_app);
g_lua.bindClassStaticFunction("g_app", "isRunning", std::bind(&Application::isRunning, g_app)); g_lua.bindSingletonFunction("g_app", "isRunning", &Application::isRunning, g_app);
g_lua.bindClassStaticFunction("g_app", "isStopping", std::bind(&Application::isStopping, g_app)); g_lua.bindSingletonFunction("g_app", "isStopping", &Application::isStopping, g_app);
g_lua.bindClassStaticFunction("g_app", "getName", std::bind(&Application::getName, g_app)); g_lua.bindSingletonFunction("g_app", "getName", &Application::getName, g_app);
g_lua.bindClassStaticFunction("g_app", "getVersion", std::bind(&Application::getVersion, g_app)); g_lua.bindSingletonFunction("g_app", "getVersion", &Application::getVersion, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildCompiler", std::bind(&Application::getBuildCompiler, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildCompiler", &Application::getBuildCompiler, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildDate", std::bind(&Application::getBuildDate, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildDate", &Application::getBuildDate, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildRevision", std::bind(&Application::getBuildRevision, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildRevision", &Application::getBuildRevision, g_app);
g_lua.bindClassStaticFunction("g_app", "getBuildType", std::bind(&Application::getBuildType, g_app)); g_lua.bindSingletonFunction("g_app", "getBuildType", &Application::getBuildType, g_app);
// ConfigManager // ConfigManager
g_lua.registerStaticClass("g_configs"); g_lua.registerSingletonClass("g_configs");
g_lua.bindClassStaticFunction("g_configs", "set", std::bind(&ConfigManager::set, &g_configs, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_configs", "set", &ConfigManager::set, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "setList", std::bind(&ConfigManager::setList, &g_configs, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_configs", "setList", &ConfigManager::setList, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "get", std::bind(&ConfigManager::get, &g_configs, std::placeholders::_1)); g_lua.bindSingletonFunction("g_configs", "get", &ConfigManager::get, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "getList", std::bind(&ConfigManager::getList, &g_configs, std::placeholders::_1)); g_lua.bindSingletonFunction("g_configs", "getList", &ConfigManager::getList, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "exists", std::bind(&ConfigManager::exists, &g_configs, std::placeholders::_1)); g_lua.bindSingletonFunction("g_configs", "exists", &ConfigManager::exists, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "remove", std::bind(&ConfigManager::remove, &g_configs, std::placeholders::_1)); g_lua.bindSingletonFunction("g_configs", "remove", &ConfigManager::remove, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "setNode", std::bind(&ConfigManager::setNode, &g_configs, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_configs", "setNode", &ConfigManager::setNode, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "addNode", std::bind(&ConfigManager::addNode, &g_configs, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_configs", "addNode", &ConfigManager::addNode, &g_configs);
g_lua.bindClassStaticFunction("g_configs", "getNode", std::bind(&ConfigManager::getNode, &g_configs, std::placeholders::_1)); g_lua.bindSingletonFunction("g_configs", "getNode", &ConfigManager::getNode, &g_configs);
// PlatformWindow // PlatformWindow
g_lua.registerStaticClass("g_window"); g_lua.registerSingletonClass("g_window");
g_lua.bindClassStaticFunction("g_window", "move", std::bind(&PlatformWindow::move, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "move", &PlatformWindow::move, &g_window);
g_lua.bindClassStaticFunction("g_window", "resize", std::bind(&PlatformWindow::resize, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "resize", &PlatformWindow::resize, &g_window);
g_lua.bindClassStaticFunction("g_window", "show", std::bind(&PlatformWindow::show, &g_window)); g_lua.bindSingletonFunction("g_window", "show", &PlatformWindow::show, &g_window);
g_lua.bindClassStaticFunction("g_window", "hide", std::bind(&PlatformWindow::hide, &g_window)); g_lua.bindSingletonFunction("g_window", "hide", &PlatformWindow::hide, &g_window);
g_lua.bindClassStaticFunction("g_window", "maximize", std::bind(&PlatformWindow::maximize, &g_window)); g_lua.bindSingletonFunction("g_window", "maximize", &PlatformWindow::maximize, &g_window);
g_lua.bindClassStaticFunction("g_window", "restoreMouseCursor", std::bind(&PlatformWindow::restoreMouseCursor, &g_window)); g_lua.bindSingletonFunction("g_window", "restoreMouseCursor", &PlatformWindow::restoreMouseCursor, &g_window);
g_lua.bindClassStaticFunction("g_window", "showMouse", std::bind(&PlatformWindow::showMouse, &g_window)); g_lua.bindSingletonFunction("g_window", "showMouse", &PlatformWindow::showMouse, &g_window);
g_lua.bindClassStaticFunction("g_window", "hideMouse", std::bind(&PlatformWindow::hideMouse, &g_window)); g_lua.bindSingletonFunction("g_window", "hideMouse", &PlatformWindow::hideMouse, &g_window);
g_lua.bindClassStaticFunction("g_window", "setTitle", std::bind(&PlatformWindow::setTitle, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "setTitle", &PlatformWindow::setTitle, &g_window);
g_lua.bindClassStaticFunction("g_window", "setMouseCursor", std::bind(&PlatformWindow::setMouseCursor, &g_window, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_window", "setMouseCursor", &PlatformWindow::setMouseCursor, &g_window);
g_lua.bindClassStaticFunction("g_window", "setMinimumSize", std::bind(&PlatformWindow::setMinimumSize, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "setMinimumSize", &PlatformWindow::setMinimumSize, &g_window);
g_lua.bindClassStaticFunction("g_window", "setFullscreen", std::bind(&PlatformWindow::setFullscreen, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "setFullscreen", &PlatformWindow::setFullscreen, &g_window);
g_lua.bindClassStaticFunction("g_window", "setVerticalSync", std::bind(&PlatformWindow::setVerticalSync, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "setVerticalSync", &PlatformWindow::setVerticalSync, &g_window);
g_lua.bindClassStaticFunction("g_window", "setIcon", std::bind(&PlatformWindow::setIcon, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "setIcon", &PlatformWindow::setIcon, &g_window);
g_lua.bindClassStaticFunction("g_window", "setClipboardText", std::bind(&PlatformWindow::setClipboardText, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "setClipboardText", &PlatformWindow::setClipboardText, &g_window);
g_lua.bindClassStaticFunction("g_window", "getDisplaySize", std::bind(&PlatformWindow::getDisplaySize, &g_window)); g_lua.bindSingletonFunction("g_window", "getDisplaySize", &PlatformWindow::getDisplaySize, &g_window);
g_lua.bindClassStaticFunction("g_window", "getClipboardText", std::bind(&PlatformWindow::getClipboardText, &g_window)); g_lua.bindSingletonFunction("g_window", "getClipboardText", &PlatformWindow::getClipboardText, &g_window);
g_lua.bindClassStaticFunction("g_window", "getPlatformType", std::bind(&PlatformWindow::getPlatformType, &g_window)); g_lua.bindSingletonFunction("g_window", "getPlatformType", &PlatformWindow::getPlatformType, &g_window);
g_lua.bindClassStaticFunction("g_window", "getDisplayWidth", std::bind(&PlatformWindow::getDisplayWidth, &g_window)); g_lua.bindSingletonFunction("g_window", "getDisplayWidth", &PlatformWindow::getDisplayWidth, &g_window);
g_lua.bindClassStaticFunction("g_window", "getDisplayHeight", std::bind(&PlatformWindow::getDisplayHeight, &g_window)); g_lua.bindSingletonFunction("g_window", "getDisplayHeight", &PlatformWindow::getDisplayHeight, &g_window);
g_lua.bindClassStaticFunction("g_window", "getUnmaximizedSize", std::bind(&PlatformWindow::getUnmaximizedSize, &g_window)); g_lua.bindSingletonFunction("g_window", "getUnmaximizedSize", &PlatformWindow::getUnmaximizedSize, &g_window);
g_lua.bindClassStaticFunction("g_window", "getSize", std::bind(&PlatformWindow::getSize, &g_window)); g_lua.bindSingletonFunction("g_window", "getSize", &PlatformWindow::getSize, &g_window);
g_lua.bindClassStaticFunction("g_window", "getWidth", std::bind(&PlatformWindow::getWidth, &g_window)); g_lua.bindSingletonFunction("g_window", "getWidth", &PlatformWindow::getWidth, &g_window);
g_lua.bindClassStaticFunction("g_window", "getHeight", std::bind(&PlatformWindow::getHeight, &g_window)); g_lua.bindSingletonFunction("g_window", "getHeight", &PlatformWindow::getHeight, &g_window);
g_lua.bindClassStaticFunction("g_window", "getUnmaximizedPos", std::bind(&PlatformWindow::getUnmaximizedPos, &g_window)); g_lua.bindSingletonFunction("g_window", "getUnmaximizedPos", &PlatformWindow::getUnmaximizedPos, &g_window);
g_lua.bindClassStaticFunction("g_window", "getPosition", std::bind(&PlatformWindow::getPosition, &g_window)); g_lua.bindSingletonFunction("g_window", "getPosition", &PlatformWindow::getPosition, &g_window);
g_lua.bindClassStaticFunction("g_window", "getX", std::bind(&PlatformWindow::getX, &g_window)); g_lua.bindSingletonFunction("g_window", "getX", &PlatformWindow::getX, &g_window);
g_lua.bindClassStaticFunction("g_window", "getY", std::bind(&PlatformWindow::getY, &g_window)); g_lua.bindSingletonFunction("g_window", "getY", &PlatformWindow::getY, &g_window);
g_lua.bindClassStaticFunction("g_window", "getMousePosition", std::bind(&PlatformWindow::getMousePosition, &g_window)); g_lua.bindSingletonFunction("g_window", "getMousePosition", &PlatformWindow::getMousePosition, &g_window);
g_lua.bindClassStaticFunction("g_window", "getKeyboardModifiers", std::bind(&PlatformWindow::getKeyboardModifiers, &g_window)); g_lua.bindSingletonFunction("g_window", "getKeyboardModifiers", &PlatformWindow::getKeyboardModifiers, &g_window);
g_lua.bindClassStaticFunction("g_window", "isKeyPressed", std::bind(&PlatformWindow::isKeyPressed, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "isKeyPressed", &PlatformWindow::isKeyPressed, &g_window);
g_lua.bindClassStaticFunction("g_window", "isMouseButtonPressed", std::bind(&PlatformWindow::isMouseButtonPressed, &g_window, std::placeholders::_1)); g_lua.bindSingletonFunction("g_window", "isMouseButtonPressed", &PlatformWindow::isMouseButtonPressed, &g_window);
g_lua.bindClassStaticFunction("g_window", "isVisible", std::bind(&PlatformWindow::isVisible, &g_window)); g_lua.bindSingletonFunction("g_window", "isVisible", &PlatformWindow::isVisible, &g_window);
g_lua.bindClassStaticFunction("g_window", "isFullscreen", std::bind(&PlatformWindow::isFullscreen, &g_window)); g_lua.bindSingletonFunction("g_window", "isFullscreen", &PlatformWindow::isFullscreen, &g_window);
g_lua.bindClassStaticFunction("g_window", "isMaximized", std::bind(&PlatformWindow::isMaximized, &g_window)); g_lua.bindSingletonFunction("g_window", "isMaximized", &PlatformWindow::isMaximized, &g_window);
g_lua.bindClassStaticFunction("g_window", "hasFocus", std::bind(&PlatformWindow::hasFocus, &g_window)); g_lua.bindSingletonFunction("g_window", "hasFocus", &PlatformWindow::hasFocus, &g_window);
// Graphics // Graphics
g_lua.registerStaticClass("g_graphics"); g_lua.registerSingletonClass("g_graphics");
g_lua.bindClassStaticFunction("g_graphics", "isPainterEngineAvailable", std::bind(&Graphics::isPainterEngineAvailable, &g_graphics, std::placeholders::_1)); g_lua.bindSingletonFunction("g_graphics", "isPainterEngineAvailable", &Graphics::isPainterEngineAvailable, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "selectPainterEngine", std::bind(&Graphics::selectPainterEngine, &g_graphics, std::placeholders::_1)); g_lua.bindSingletonFunction("g_graphics", "selectPainterEngine", &Graphics::selectPainterEngine, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "canCacheBackbuffer", std::bind(&Graphics::canCacheBackbuffer, &g_graphics)); g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "getPainterEngine", std::bind(&Graphics::getPainterEngine, &g_graphics)); g_lua.bindSingletonFunction("g_graphics", "getPainterEngine", &Graphics::getPainterEngine, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "getViewportSize", std::bind(&Graphics::getViewportSize, &g_graphics)); g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "getVendor", std::bind(&Graphics::getVendor, &g_graphics)); g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "getRenderer", std::bind(&Graphics::getRenderer, &g_graphics)); g_lua.bindSingletonFunction("g_graphics", "getRenderer", &Graphics::getRenderer, &g_graphics);
g_lua.bindClassStaticFunction("g_graphics", "getVersion", std::bind(&Graphics::getVersion, &g_graphics)); g_lua.bindSingletonFunction("g_graphics", "getVersion", &Graphics::getVersion, &g_graphics);
// Logger // Logger
g_lua.registerStaticClass("g_logger"); g_lua.registerSingletonClass("g_logger");
g_lua.bindClassStaticFunction("g_logger", "log", std::bind(&Logger::log, &g_logger, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_logger", "log", &Logger::log, &g_logger);
g_lua.bindClassStaticFunction("g_logger", "fireOldMessages", std::bind(&Logger::fireOldMessages, &g_logger)); g_lua.bindSingletonFunction("g_logger", "fireOldMessages", &Logger::fireOldMessages, &g_logger);
g_lua.bindClassStaticFunction("g_logger", "setOnLog", std::bind(&Logger::setOnLog, &g_logger, std::placeholders::_1)); g_lua.bindSingletonFunction("g_logger", "setOnLog", &Logger::setOnLog, &g_logger);
// UI // UI
g_lua.registerStaticClass("g_ui"); g_lua.registerSingletonClass("g_ui");
g_lua.bindClassStaticFunction("g_ui", "clearStyles", std::bind(&UIManager::clearStyles, &g_ui)); g_lua.bindSingletonFunction("g_ui", "clearStyles", &UIManager::clearStyles, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "importStyle", std::bind(&UIManager::importStyle, &g_ui, std::placeholders::_1)); g_lua.bindSingletonFunction("g_ui", "importStyle", &UIManager::importStyle, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "getStyle", std::bind(&UIManager::getStyle, &g_ui, std::placeholders::_1)); g_lua.bindSingletonFunction("g_ui", "getStyle", &UIManager::getStyle, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, std::placeholders::_1)); g_lua.bindSingletonFunction("g_ui", "getStyleClass", &UIManager::getStyleClass, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_ui", "loadUI", &UIManager::loadUI, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "createWidgetFromStyle", std::bind(&UIManager::createWidgetFromStyle, &g_ui, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_ui", "createWidgetFromStyle", &UIManager::createWidgetFromStyle, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "createWidgetFromOTML", std::bind(&UIManager::createWidgetFromOTML, &g_ui, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_ui", "createWidgetFromOTML", &UIManager::createWidgetFromOTML, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); g_lua.bindSingletonFunction("g_ui", "getRootWidget", &UIManager::getRootWidget, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "getDraggingWidget", std::bind(&UIManager::getDraggingWidget, &g_ui)); g_lua.bindSingletonFunction("g_ui", "getDraggingWidget", &UIManager::getDraggingWidget, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "getPressedWidget", std::bind(&UIManager::getPressedWidget, &g_ui)); g_lua.bindSingletonFunction("g_ui", "getPressedWidget", &UIManager::getPressedWidget, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, std::placeholders::_1)); g_lua.bindSingletonFunction("g_ui", "setDebugBoxesDrawing", &UIManager::setDebugBoxesDrawing, &g_ui);
g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, std::placeholders::_1)); g_lua.bindSingletonFunction("g_ui", "isDrawingDebugBoxes", &UIManager::setDebugBoxesDrawing, &g_ui);
// ModuleManager // ModuleManager
g_lua.registerStaticClass("g_modules"); g_lua.registerSingletonClass("g_modules");
g_lua.bindClassStaticFunction("g_modules", "discoverModulesPath", std::bind(&ModuleManager::discoverModulesPath, &g_modules)); g_lua.bindSingletonFunction("g_modules", "discoverModulesPath", &ModuleManager::discoverModulesPath, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "discoverModules", std::bind(&ModuleManager::discoverModules, &g_modules)); g_lua.bindSingletonFunction("g_modules", "discoverModules", &ModuleManager::discoverModules, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "autoLoadModules", std::bind(&ModuleManager::autoLoadModules, &g_modules, std::placeholders::_1)); g_lua.bindSingletonFunction("g_modules", "autoLoadModules", &ModuleManager::autoLoadModules, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "discoverModule", std::bind(&ModuleManager::discoverModule, &g_modules, std::placeholders::_1)); g_lua.bindSingletonFunction("g_modules", "discoverModule", &ModuleManager::discoverModule, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "ensureModuleLoaded", std::bind(&ModuleManager::ensureModuleLoaded, &g_modules, std::placeholders::_1)); g_lua.bindSingletonFunction("g_modules", "ensureModuleLoaded", &ModuleManager::ensureModuleLoaded, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "unloadModules", std::bind(&ModuleManager::unloadModules, &g_modules)); g_lua.bindSingletonFunction("g_modules", "unloadModules", &ModuleManager::unloadModules, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "reloadModules", std::bind(&ModuleManager::reloadModules, &g_modules)); g_lua.bindSingletonFunction("g_modules", "reloadModules", &ModuleManager::reloadModules, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "getModule", std::bind(&ModuleManager::getModule, &g_modules, std::placeholders::_1)); g_lua.bindSingletonFunction("g_modules", "getModule", &ModuleManager::getModule, &g_modules);
g_lua.bindClassStaticFunction("g_modules", "getModules", std::bind(&ModuleManager::getModules, &g_modules)); g_lua.bindSingletonFunction("g_modules", "getModules", &ModuleManager::getModules, &g_modules);
// FontManager // FontManager
g_lua.registerStaticClass("g_fonts"); g_lua.registerSingletonClass("g_fonts");
g_lua.bindClassStaticFunction("g_fonts", "importFont", std::bind(&FontManager::importFont, &g_fonts, std::placeholders::_1)); g_lua.bindSingletonFunction("g_fonts", "importFont", &FontManager::importFont, &g_fonts);
g_lua.bindClassStaticFunction("g_fonts", "fontExists", std::bind(&FontManager::fontExists, &g_fonts, std::placeholders::_1)); g_lua.bindSingletonFunction("g_fonts", "fontExists", &FontManager::fontExists, &g_fonts);
g_lua.bindClassStaticFunction("g_fonts", "setDefaultFont", std::bind(&FontManager::setDefaultFont, &g_fonts, std::placeholders::_1)); g_lua.bindSingletonFunction("g_fonts", "setDefaultFont", &FontManager::setDefaultFont, &g_fonts);
// SoundManager // SoundManager
g_lua.registerStaticClass("g_sounds"); g_lua.registerSingletonClass("g_sounds");
g_lua.bindClassStaticFunction("g_sounds", "preload", std::bind(&SoundManager::preload, &g_sounds, std::placeholders::_1)); g_lua.bindSingletonFunction("g_sounds", "preload", &SoundManager::preload, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "enableSound", std::bind(&SoundManager::enableSound, &g_sounds, std::placeholders::_1)); g_lua.bindSingletonFunction("g_sounds", "enableSound", &SoundManager::enableSound, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "play", std::bind(&SoundManager::play, &g_sounds, std::placeholders::_1)); g_lua.bindSingletonFunction("g_sounds", "play", &SoundManager::play, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "enableMusic", std::bind(&SoundManager::enableMusic, &g_sounds, std::placeholders::_1)); g_lua.bindSingletonFunction("g_sounds", "enableMusic", &SoundManager::enableMusic, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "playMusic", std::bind(&SoundManager::playMusic, &g_sounds, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_sounds", "playMusic", &SoundManager::playMusic, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "stopMusic", std::bind(&SoundManager::stopMusic, &g_sounds, std::placeholders::_1)); g_lua.bindSingletonFunction("g_sounds", "stopMusic", &SoundManager::stopMusic, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "isMusicEnabled", std::bind(&SoundManager::isMusicEnabled, &g_sounds)); g_lua.bindSingletonFunction("g_sounds", "isMusicEnabled", &SoundManager::isMusicEnabled, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "isSoundEnabled", std::bind(&SoundManager::isSoundEnabled, &g_sounds)); g_lua.bindSingletonFunction("g_sounds", "isSoundEnabled", &SoundManager::isSoundEnabled, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "isAudioEnabled", std::bind(&SoundManager::isAudioEnabled, &g_sounds)); g_lua.bindSingletonFunction("g_sounds", "isAudioEnabled", &SoundManager::isAudioEnabled, &g_sounds);
g_lua.bindClassStaticFunction("g_sounds", "getCurrentMusic", std::bind(&SoundManager::getCurrentMusic, &g_sounds)); g_lua.bindSingletonFunction("g_sounds", "getCurrentMusic", &SoundManager::getCurrentMusic, &g_sounds);
// EventDispatcher // EventDispatcher
g_lua.registerStaticClass("g_eventDispatcher"); g_lua.registerSingletonClass("g_eventDispatcher");
g_lua.bindClassStaticFunction("g_eventDispatcher", "addEvent", std::bind(&EventDispatcher::addEvent, &g_eventDispatcher, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_eventDispatcher", "addEvent", &EventDispatcher::addEvent, &g_eventDispatcher);
g_lua.bindClassStaticFunction("g_eventDispatcher", "scheduleEvent", std::bind(&EventDispatcher::scheduleEvent, &g_eventDispatcher, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_eventDispatcher", "scheduleEvent", &EventDispatcher::scheduleEvent, &g_eventDispatcher);
g_lua.bindClassStaticFunction("g_eventDispatcher", "cycleEvent", std::bind(&EventDispatcher::cycleEvent, &g_eventDispatcher, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_eventDispatcher", "cycleEvent", &EventDispatcher::cycleEvent, &g_eventDispatcher);
} }

View File

@ -55,7 +55,7 @@ namespace luabinder
template<> template<>
struct pack_values_into_tuple<0> { struct pack_values_into_tuple<0> {
template<typename Tuple> template<typename Tuple>
static void call(Tuple &tuple, LuaInterface* lua) { } static void call(Tuple& tuple, LuaInterface* lua) { }
}; };
/// C++ function caller that can push results to lua /// C++ function caller that can push results to lua
@ -135,7 +135,7 @@ namespace luabinder
}; };
template<typename Lambda> template<typename Lambda>
typename std::enable_if<std::is_class<Lambda>::value, LuaCppFunction>::type bind_fun(const Lambda& f) { typename std::enable_if<std::is_constructible<decltype(&Lambda::operator())>::value, LuaCppFunction>::type bind_fun(const Lambda& f) {
typedef decltype(&Lambda::operator()) F; typedef decltype(&Lambda::operator()) F;
return bind_lambda_fun<F>::call(f); return bind_lambda_fun<F>::call(f);
} }
@ -146,102 +146,58 @@ namespace luabinder
return bind_fun(std::function<Ret(Args...)>(f)); return bind_fun(std::function<Ret(Args...)>(f));
} }
// a tuple_element that works with the next algorithm /// Create member function lambdas
template<std::size_t __i, typename _Tp> template<typename Ret, typename C, typename... Args>
struct tuple_element; std::function<Ret(const std::shared_ptr<C>&, const Args&...)> make_mem_func(Ret (C::* f)(Args...)) {
template<std::size_t __i, typename _Head, typename... _Tail> auto mf = std::mem_fn(f);
struct tuple_element<__i, std::tuple<_Head, _Tail...> > return [=](const std::shared_ptr<C>& obj, const Args&... args) mutable -> Ret {
: tuple_element<__i - 1, std::tuple<_Tail...> > { }; if(!obj)
template<typename _Head, typename... _Tail> throw LuaException("failed to call a member function because the passed object is nil");
struct tuple_element<0, std::tuple<_Head, _Tail...> > { typedef _Head type; }; return mf(obj.get(), args...);
template<typename _Head> };
struct tuple_element<-1,std::tuple<_Head>> { typedef void type; }; }
template<std::size_t __i> template<typename C, typename... Args>
struct tuple_element<__i,std::tuple<>> { typedef void type; }; std::function<void(const std::shared_ptr<C>&, const Args&...)> make_mem_func(void (C::* f)(Args...)) {
auto mf = std::mem_fn(f);
template<typename Enable, int N, typename ArgsTuple, typename HoldersTuple, typename... Args> return [=](const std::shared_ptr<C>& obj, const Args&... args) mutable -> void {
struct get_holded_tuple; if(!obj)
throw LuaException("failed to call a member function because the passed object is nil");
// some dirty stuff to extract arguments from std::bind holders mf(obj.get(), args...);
template<int N, typename ArgsTuple, typename HoldersTuple, typename... Args> };
struct get_holded_tuple<
typename std::enable_if<
(N > 0 && std::is_placeholder<
typename tuple_element<N-1, HoldersTuple>::type
>::value > 0), void
>::type, N, ArgsTuple, HoldersTuple, Args...> {
typedef typename std::tuple_element<N-1, HoldersTuple>::type holder_type;
typedef typename tuple_element<std::is_placeholder<holder_type>::value-1, ArgsTuple>::type _arg_type;
typedef typename remove_const_ref<_arg_type>::type arg_type;
typedef typename get_holded_tuple<void, N-1, ArgsTuple, HoldersTuple, arg_type, Args...>::type type;
};
template<int N, typename ArgsTuple, typename HoldersTuple, typename... Args>
struct get_holded_tuple<typename std::enable_if<(N > 0 && std::is_placeholder<typename tuple_element<N-1, HoldersTuple>::type>::value == 0), void>::type, N, ArgsTuple, HoldersTuple, Args...> {
typedef typename get_holded_tuple<void, N-1, ArgsTuple, HoldersTuple, Args...>::type type;
};
template<typename ArgsTuple, typename HoldersTuple, typename... Args>
struct get_holded_tuple<void, 0, ArgsTuple, HoldersTuple, Args...> {
typedef typename std::tuple<Args...> type;
};
/// Rebind functions already bound by std::bind handling it's placeholders
template<typename Ret, typename... Args, typename... Holders>
LuaCppFunction bind_fun(const std::_Bind<Ret (*(Holders...))(Args...)>& f) {
typedef typename std::tuple<Args...> ArgsTuple;
typedef typename std::tuple<Holders...> HoldersTuple;
typedef typename get_holded_tuple<void, sizeof...(Holders), ArgsTuple, HoldersTuple>::type Tuple;
return bind_fun_specializer<typename remove_const_ref<Ret>::type,
decltype(f),
Tuple>(f);
} }
/// Rebind member functions already bound by std::bind handling it's placeholders /// Create member function lambdas for singleton classes
template<typename Obj, typename Ret, typename... Args, typename... Holders> template<typename Ret, typename C, typename... Args>
LuaCppFunction bind_fun(const std::_Bind<std::_Mem_fn<Ret (Obj::*)(Args...)>(Obj*, Holders...)>& f) { std::function<Ret(const Args&...)> make_mem_func_singleton(Ret (C::* f)(Args...), C* instance) {
typedef typename std::tuple<Args...> ArgsTuple; auto mf = std::mem_fn(f);
typedef typename std::tuple<Holders...> HoldersTuple; return [=](Args... args) mutable -> Ret { return mf(instance, args...); };
typedef typename get_holded_tuple<void, sizeof...(Holders), ArgsTuple, HoldersTuple>::type Tuple; }
return bind_fun_specializer<typename remove_const_ref<Ret>::type, template<typename C, typename... Args>
decltype(f), std::function<void(const Args&...)> make_mem_func_singleton(void (C::* f)(Args...), C* instance) {
Tuple>(f); auto mf = std::mem_fn(f);
return [=](Args... args) mutable -> void { mf(instance, args...); };
} }
template<typename Obj, typename Ret, typename... Args, typename... Holders>
LuaCppFunction bind_fun(const std::_Bind<std::_Mem_fn<Ret (Obj::*)(Args...) const>(Obj*, Holders...)>& f) {
typedef typename std::tuple<Args...> ArgsTuple;
typedef typename std::tuple<Holders...> HoldersTuple;
typedef typename get_holded_tuple<void, sizeof...(Holders), ArgsTuple, HoldersTuple>::type Tuple;
return bind_fun_specializer<typename remove_const_ref<Ret>::type,
decltype(f),
Tuple>(f);
}
/// Bind customized functions already bound by std::bind
template<typename Obj>
LuaCppFunction bind_fun(const std::_Bind<std::_Mem_fn<int (Obj::*)(LuaInterface*)>(Obj*, std::_Placeholder<1>)>& f) {
return f;
}
inline
LuaCppFunction bind_fun(const std::_Bind<int (*(std::_Placeholder<1>))(LuaInterface*)>& f) {
return f;
}
/// Bind member functions /// Bind member functions
template<typename C, typename Ret, class FC, typename... Args> template<typename C, typename Ret, class FC, typename... Args>
LuaCppFunction bind_mem_fun(Ret (FC::*f)(Args...)) { LuaCppFunction bind_mem_fun(Ret (FC::* f)(Args...)) {
auto mf = std::mem_fn(f); typedef typename std::tuple<std::shared_ptr<FC>, typename remove_const_ref<Args>::type...> Tuple;
typedef typename std::tuple<std::shared_ptr<C>, typename remove_const_ref<Args>::type...> Tuple; auto lambda = make_mem_func<Ret,FC>(f);
return bind_fun_specializer<typename remove_const_ref<Ret>::type, return bind_fun_specializer<typename remove_const_ref<Ret>::type,
decltype(mf), decltype(lambda),
Tuple>(mf); Tuple>(lambda);
} }
/// Bind singleton member functions
template<typename C, typename Ret, class FC, typename... Args> template<typename C, typename Ret, class FC, typename... Args>
LuaCppFunction bind_mem_fun(Ret (FC::*f)(Args...) const) { LuaCppFunction bind_singleton_mem_fun(Ret (FC::*f)(Args...), C *instance) {
auto mf = std::mem_fn(f); typedef typename std::tuple<typename remove_const_ref<Args>::type...> Tuple;
typedef typename std::tuple<std::shared_ptr<C>, typename remove_const_ref<Args>::type...> Tuple; assert(instance);
auto lambda = make_mem_func_singleton<Ret,FC>(f, static_cast<FC*>(instance));
return bind_fun_specializer<typename remove_const_ref<Ret>::type, return bind_fun_specializer<typename remove_const_ref<Ret>::type,
decltype(mf), decltype(lambda),
Tuple>(mf); Tuple>(lambda);
} }
/// Bind customized member functions /// Bind customized member functions

View File

@ -66,7 +66,7 @@ void LuaInterface::terminate()
closeLuaState(); closeLuaState();
} }
void LuaInterface::registerStaticClass(const std::string& className) void LuaInterface::registerSingletonClass(const std::string& className)
{ {
newTable(); newTable();
pushValue(); pushValue();

View File

@ -42,7 +42,7 @@ public:
void registerFunctions(); void registerFunctions();
// functions that will register all script stuff in lua global environment // functions that will register all script stuff in lua global environment
void registerStaticClass(const std::string& className); void registerSingletonClass(const std::string& className);
void registerClass(const std::string& className, const std::string& baseClass = "LuaObject"); void registerClass(const std::string& className, const std::string& baseClass = "LuaObject");
void registerClassStaticFunction(const std::string& className, void registerClassStaticFunction(const std::string& className,
@ -85,6 +85,11 @@ public:
} }
// methods for binding functions // methods for binding functions
template<class C, typename F>
void bindSingletonFunction(const std::string& functionName, F C::*function, C *instance);
template<class C, typename F>
void bindSingletonFunction(const std::string& className, const std::string& functionName, F C::*function, C *instance);
template<class C, typename F> template<class C, typename F>
void bindClassStaticFunction(const std::string& functionName, const F& function); void bindClassStaticFunction(const std::string& functionName, const F& function);
template<typename F> template<typename F>
@ -340,6 +345,17 @@ void LuaInterface::polymorphicPush(T v, Args... args) {
} }
// next templates must be defined after above includes // next templates must be defined after above includes
template<class C, typename F>
void LuaInterface::bindSingletonFunction(const std::string& functionName, F C::*function, C *instance) {
registerClassStaticFunction<C>(functionName, luabinder::bind_singleton_mem_fun(function, instance));
}
template<class C, typename F>
void LuaInterface::bindSingletonFunction(const std::string& className, const std::string& functionName, F C::*function, C *instance) {
registerClassStaticFunction(className, functionName, luabinder::bind_singleton_mem_fun(function, instance));
}
template<class C, typename F> template<class C, typename F>
void LuaInterface::bindClassStaticFunction(const std::string& functionName, const F& function) { void LuaInterface::bindClassStaticFunction(const std::string& functionName, const F& function) {
registerClassStaticFunction<C>(functionName, luabinder::bind_fun(function)); registerClassStaticFunction<C>(functionName, luabinder::bind_fun(function));

View File

@ -68,7 +68,7 @@ public:
int getUseCount(); int getUseCount();
/// Returns the derived class name, its the same name used in Lua /// Returns the derived class name, its the same name used in Lua
std::string getClassName() const { std::string getClassName() {
// TODO: this could be cached for more performance // TODO: this could be cached for more performance
return stdext::demangle_name(typeid(*this).name()); return stdext::demangle_name(typeid(*this).name());
} }

View File

@ -57,9 +57,9 @@ public:
void setErrorCallback(const ErrorCallback& errorCallback) { m_errorCallback = errorCallback; } void setErrorCallback(const ErrorCallback& errorCallback) { m_errorCallback = errorCallback; }
boost::system::error_code getError() const { return m_error; } boost::system::error_code getError() { return m_error; }
bool isConnecting() const { return m_connecting; } bool isConnecting() { return m_connecting; }
bool isConnected() const { return m_connected; } bool isConnected() { return m_connected; }
protected: protected:
void onConnect(const boost::system::error_code& error); void onConnect(const boost::system::error_code& error);

View File

@ -41,7 +41,7 @@ OTMLNodePtr OTMLNode::create(std::string tag, std::string value)
return node; return node;
} }
bool OTMLNode::hasChildren() const bool OTMLNode::hasChildren()
{ {
int count = 0; int count = 0;
for(const OTMLNodePtr& child : m_children) { for(const OTMLNodePtr& child : m_children) {
@ -51,7 +51,7 @@ bool OTMLNode::hasChildren() const
return count > 0; return count > 0;
} }
OTMLNodePtr OTMLNode::get(const std::string& childTag) const OTMLNodePtr OTMLNode::get(const std::string& childTag)
{ {
for(const OTMLNodePtr& child : m_children) { for(const OTMLNodePtr& child : m_children) {
if(child->tag() == childTag && !child->isNull()) if(child->tag() == childTag && !child->isNull())
@ -60,7 +60,7 @@ OTMLNodePtr OTMLNode::get(const std::string& childTag) const
return nullptr; return nullptr;
} }
OTMLNodePtr OTMLNode::getIndex(int childIndex) const OTMLNodePtr OTMLNode::getIndex(int childIndex)
{ {
if(childIndex < size() && childIndex >= 0) if(childIndex < size() && childIndex >= 0)
return m_children[childIndex]; return m_children[childIndex];
@ -174,7 +174,7 @@ void OTMLNode::clear()
m_children.clear(); m_children.clear();
} }
OTMLNodeList OTMLNode::children() const OTMLNodeList OTMLNode::children()
{ {
OTMLNodeList children; OTMLNodeList children;
for(const OTMLNodePtr& child : m_children) for(const OTMLNodePtr& child : m_children)
@ -183,7 +183,7 @@ OTMLNodeList OTMLNode::children() const
return children; return children;
} }
OTMLNodePtr OTMLNode::clone() const OTMLNodePtr OTMLNode::clone()
{ {
OTMLNodePtr myClone(new OTMLNode); OTMLNodePtr myClone(new OTMLNode);
myClone->setTag(m_tag); myClone->setTag(m_tag);

View File

@ -33,17 +33,17 @@ public:
static OTMLNodePtr create(std::string tag = "", bool unique = false); static OTMLNodePtr create(std::string tag = "", bool unique = false);
static OTMLNodePtr create(std::string tag, std::string value); static OTMLNodePtr create(std::string tag, std::string value);
std::string tag() const { return m_tag; } std::string tag() { return m_tag; }
int size() const { return m_children.size(); } int size() { return m_children.size(); }
OTMLNodePtr parent() const { return m_parent.lock(); } OTMLNodePtr parent() { return m_parent.lock(); }
std::string source() const { return m_source; } std::string source() { return m_source; }
bool isUnique() const { return m_unique; } bool isUnique() { return m_unique; }
bool isNull() const { return m_null; } bool isNull() { return m_null; }
bool hasTag() const { return !m_tag.empty(); } bool hasTag() { return !m_tag.empty(); }
bool hasValue() const { return !m_value.empty(); } bool hasValue() { return !m_value.empty(); }
bool hasChildren() const; bool hasChildren();
bool hasChildAt(const std::string& childTag) { return !!get(childTag); } bool hasChildAt(const std::string& childTag) { return !!get(childTag); }
bool hasChildAtIndex(int childIndex) { return !!getIndex(childIndex); } bool hasChildAtIndex(int childIndex) { return !!getIndex(childIndex); }
@ -54,8 +54,8 @@ public:
void setParent(const OTMLNodePtr& parent) { m_parent = parent; } void setParent(const OTMLNodePtr& parent) { m_parent = parent; }
void setSource(const std::string& source) { m_source = source; } void setSource(const std::string& source) { m_source = source; }
OTMLNodePtr get(const std::string& childTag) const; OTMLNodePtr get(const std::string& childTag);
OTMLNodePtr getIndex(int childIndex) const; OTMLNodePtr getIndex(int childIndex);
OTMLNodePtr at(const std::string& childTag); OTMLNodePtr at(const std::string& childTag);
OTMLNodePtr atIndex(int childIndex); OTMLNodePtr atIndex(int childIndex);
@ -67,8 +67,8 @@ public:
void merge(const OTMLNodePtr& node); void merge(const OTMLNodePtr& node);
void clear(); void clear();
OTMLNodeList children() const; OTMLNodeList children();
OTMLNodePtr clone() const; OTMLNodePtr clone();
template<typename T = std::string> template<typename T = std::string>
T value(); T value();

View File

@ -29,7 +29,7 @@
namespace stdext { namespace stdext {
const static std::chrono::system_clock::time_point startup_time = std::chrono::high_resolution_clock::now(); const static auto startup_time = std::chrono::high_resolution_clock::now();
inline ticks_t millis() { return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count(); } inline ticks_t millis() { return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count(); }
inline ticks_t micros() { return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count(); } inline ticks_t micros() { return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count(); }
inline void millisleep(uint32 ms) { usleep(ms * 1000); }; inline void millisleep(uint32 ms) { usleep(ms * 1000); };

View File

@ -49,8 +49,8 @@ public:
UIAnchorGroup() : m_updated(true) { } UIAnchorGroup() : m_updated(true) { }
void addAnchor(const UIAnchor& anchor); void addAnchor(const UIAnchor& anchor);
const UIAnchorList& getAnchors() const { return m_anchors; } const UIAnchorList& getAnchors() { return m_anchors; }
bool isUpdated() const { return m_updated; } bool isUpdated() { return m_updated; }
void setUpdated(bool updated) { m_updated = updated; } void setUpdated(bool updated) { m_updated = updated; }
private: private:

View File

@ -56,10 +56,10 @@ public:
int getAddons() const { return m_addons; } int getAddons() const { return m_addons; }
ThingsType::Categories getCategory() const { return m_category; } ThingsType::Categories getCategory() const { return m_category; }
Color getHeadColor() { return m_headColor; } Color getHeadColor() const { return m_headColor; }
Color getBodyColor() { return m_bodyColor; } Color getBodyColor() const { return m_bodyColor; }
Color getLegsColor() { return m_legsColor; } Color getLegsColor() const { return m_legsColor; }
Color getFeetColor() { return m_feetColor; } Color getFeetColor() const { return m_feetColor; }
private: private:
ThingsType::Categories m_category; ThingsType::Categories m_category;

View File

@ -49,138 +49,138 @@ void OTClient::registerLuaFunctions()
{ {
Application::registerLuaFunctions(); Application::registerLuaFunctions();
g_lua.registerStaticClass("g_thingsType"); g_lua.registerSingletonClass("g_thingsType");
g_lua.bindClassStaticFunction("g_thingsType", "load", std::bind(&ThingsType::load, &g_thingsType, std::placeholders::_1)); g_lua.bindSingletonFunction("g_thingsType", "load", &ThingsType::load, &g_thingsType);
g_lua.bindClassStaticFunction("g_thingsType", "isLoaded", std::bind(&ThingsType::isLoaded, &g_thingsType)); g_lua.bindSingletonFunction("g_thingsType", "isLoaded", &ThingsType::isLoaded, &g_thingsType);
g_lua.bindClassStaticFunction("g_thingsType", "getSignature", std::bind(&ThingsType::getSignature, &g_thingsType)); g_lua.bindSingletonFunction("g_thingsType", "getSignature", &ThingsType::getSignature, &g_thingsType);
g_lua.registerStaticClass("g_sprites"); g_lua.registerSingletonClass("g_sprites");
g_lua.bindClassStaticFunction("g_sprites", "load", std::bind(&SpriteManager::load, &g_sprites, std::placeholders::_1)); g_lua.bindSingletonFunction("g_sprites", "load", &SpriteManager::load, &g_sprites);
g_lua.bindClassStaticFunction("g_sprites", "unload", std::bind(&SpriteManager::unload, &g_sprites)); g_lua.bindSingletonFunction("g_sprites", "unload", &SpriteManager::unload, &g_sprites);
g_lua.bindClassStaticFunction("g_sprites", "isLoaded", std::bind(&SpriteManager::isLoaded, &g_sprites)); g_lua.bindSingletonFunction("g_sprites", "isLoaded", &SpriteManager::isLoaded, &g_sprites);
g_lua.bindClassStaticFunction("g_sprites", "getSignature", std::bind(&SpriteManager::getSignature, &g_sprites)); g_lua.bindSingletonFunction("g_sprites", "getSignature", &SpriteManager::getSignature, &g_sprites);
g_lua.bindClassStaticFunction("g_sprites", "getSpritesCount", std::bind(&SpriteManager::getSpritesCount, &g_sprites)); g_lua.bindSingletonFunction("g_sprites", "getSpritesCount", &SpriteManager::getSpritesCount, &g_sprites);
g_lua.registerStaticClass("g_map"); g_lua.registerSingletonClass("g_map");
g_lua.bindClassStaticFunction("g_map", "isLookPossible", std::bind(&Map::isLookPossible, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "isLookPossible", &Map::isLookPossible, &g_map);
g_lua.bindClassStaticFunction("g_map", "isCovered", std::bind(&Map::isCovered, &g_map, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_map", "isCovered", &Map::isCovered, &g_map);
g_lua.bindClassStaticFunction("g_map", "isCompletelyCovered", std::bind(&Map::isCompletelyCovered, &g_map, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_map", "isCompletelyCovered", &Map::isCompletelyCovered, &g_map);
g_lua.bindClassStaticFunction("g_map", "addThing", std::bind(&Map::addThing, &g_map, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_map", "addThing", &Map::addThing, &g_map);
g_lua.bindClassStaticFunction("g_map", "getThing", std::bind(&Map::getThing, &g_map, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_map", "getThing", &Map::getThing, &g_map);
g_lua.bindClassStaticFunction("g_map", "removeThingByPos", std::bind(&Map::removeThingByPos, &g_map, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_map", "removeThingByPos", &Map::removeThingByPos, &g_map);
g_lua.bindClassStaticFunction("g_map", "removeThing", std::bind(&Map::removeThing, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "removeThing", &Map::removeThing, &g_map);
g_lua.bindClassStaticFunction("g_map", "cleanTile", std::bind(&Map::cleanTile, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "cleanTile", &Map::cleanTile, &g_map);
g_lua.bindClassStaticFunction("g_map", "cleanTexts", std::bind(&Map::cleanTexts, &g_map)); g_lua.bindSingletonFunction("g_map", "cleanTexts", &Map::cleanTexts, &g_map);
g_lua.bindClassStaticFunction("g_map", "getTile", std::bind(&Map::getTile, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "getTile", &Map::getTile, &g_map);
g_lua.bindClassStaticFunction("g_map", "setCentralPosition", std::bind(&Map::setCentralPosition, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "setCentralPosition", &Map::setCentralPosition, &g_map);
g_lua.bindClassStaticFunction("g_map", "getCentralPosition", std::bind(&Map::getCentralPosition, &g_map)); g_lua.bindSingletonFunction("g_map", "getCentralPosition", &Map::getCentralPosition, &g_map);
g_lua.bindClassStaticFunction("g_map", "getCreatureById", std::bind(&Map::getCreatureById, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "getCreatureById", &Map::getCreatureById, &g_map);
g_lua.bindClassStaticFunction("g_map", "removeCreatureById", std::bind(&Map::removeCreatureById, &g_map, std::placeholders::_1)); g_lua.bindSingletonFunction("g_map", "removeCreatureById", &Map::removeCreatureById, &g_map);
g_lua.bindClassStaticFunction("g_map", "getSpectators", std::bind(&Map::getSpectators, &g_map, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_map", "getSpectators", &Map::getSpectators, &g_map);
g_lua.bindClassStaticFunction("g_map", "findPath", std::bind(&Map::findPath, &g_map, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_map", "findPath", &Map::findPath, &g_map);
g_lua.registerStaticClass("g_game"); g_lua.registerSingletonClass("g_game");
g_lua.bindClassStaticFunction("g_game", "loginWorld", std::bind(&Game::loginWorld, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6)); g_lua.bindSingletonFunction("g_game", "loginWorld", &Game::loginWorld, &g_game);
g_lua.bindClassStaticFunction("g_game", "cancelLogin", std::bind(&Game::cancelLogin, &g_game)); g_lua.bindSingletonFunction("g_game", "cancelLogin", &Game::cancelLogin, &g_game);
g_lua.bindClassStaticFunction("g_game", "forceLogout", std::bind(&Game::forceLogout, &g_game)); g_lua.bindSingletonFunction("g_game", "forceLogout", &Game::forceLogout, &g_game);
g_lua.bindClassStaticFunction("g_game", "safeLogout", std::bind(&Game::safeLogout, &g_game)); g_lua.bindSingletonFunction("g_game", "safeLogout", &Game::safeLogout, &g_game);
g_lua.bindClassStaticFunction("g_game", "walk", std::bind(&Game::walk, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "walk", &Game::walk, &g_game);
g_lua.bindClassStaticFunction("g_game", "autoWalk", std::bind(&Game::autoWalk, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "autoWalk", &Game::autoWalk, &g_game);
g_lua.bindClassStaticFunction("g_game", "forceWalk", std::bind(&Game::forceWalk, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "forceWalk", &Game::forceWalk, &g_game);
g_lua.bindClassStaticFunction("g_game", "turn", std::bind(&Game::turn, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "turn", &Game::turn, &g_game);
g_lua.bindClassStaticFunction("g_game", "stop", std::bind(&Game::stop, &g_game)); g_lua.bindSingletonFunction("g_game", "stop", &Game::stop, &g_game);
g_lua.bindClassStaticFunction("g_game", "look", std::bind(&Game::look, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "look", &Game::look, &g_game);
g_lua.bindClassStaticFunction("g_game", "move", std::bind(&Game::move, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_game", "move", &Game::move, &g_game);
g_lua.bindClassStaticFunction("g_game", "moveToParentContainer", std::bind(&Game::moveToParentContainer, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "moveToParentContainer", &Game::moveToParentContainer, &g_game);
g_lua.bindClassStaticFunction("g_game", "rotate", std::bind(&Game::rotate, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "rotate", &Game::rotate, &g_game);
g_lua.bindClassStaticFunction("g_game", "use", std::bind(&Game::use, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "use", &Game::use, &g_game);
g_lua.bindClassStaticFunction("g_game", "useWith", std::bind(&Game::useWith, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "useWith", &Game::useWith, &g_game);
g_lua.bindClassStaticFunction("g_game", "useInventoryItem", std::bind(&Game::useInventoryItem, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "useInventoryItem", &Game::useInventoryItem, &g_game);
g_lua.bindClassStaticFunction("g_game", "useInventoryItemWith", std::bind(&Game::useInventoryItemWith, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "useInventoryItemWith", &Game::useInventoryItemWith, &g_game);
g_lua.bindClassStaticFunction("g_game", "open", std::bind(&Game::open, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "open", &Game::open, &g_game);
g_lua.bindClassStaticFunction("g_game", "openParent", std::bind(&Game::openParent, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "openParent", &Game::openParent, &g_game);
g_lua.bindClassStaticFunction("g_game", "close", std::bind(&Game::close, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "close", &Game::close, &g_game);
g_lua.bindClassStaticFunction("g_game", "refreshContainer", std::bind(&Game::refreshContainer, &g_game)); g_lua.bindSingletonFunction("g_game", "refreshContainer", &Game::refreshContainer, &g_game);
g_lua.bindClassStaticFunction("g_game", "attack", std::bind(&Game::attack, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "attack", &Game::attack, &g_game);
g_lua.bindClassStaticFunction("g_game", "cancelAttack", std::bind(&Game::cancelAttack, &g_game)); g_lua.bindSingletonFunction("g_game", "cancelAttack", &Game::cancelAttack, &g_game);
g_lua.bindClassStaticFunction("g_game", "follow", std::bind(&Game::follow, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "follow", &Game::follow, &g_game);
g_lua.bindClassStaticFunction("g_game", "cancelFollow", std::bind(&Game::cancelFollow, &g_game)); g_lua.bindSingletonFunction("g_game", "cancelFollow", &Game::cancelFollow, &g_game);
g_lua.bindClassStaticFunction("g_game", "cancelAttackAndFollow", std::bind(&Game::cancelAttackAndFollow, &g_game)); g_lua.bindSingletonFunction("g_game", "cancelAttackAndFollow", &Game::cancelAttackAndFollow, &g_game);
g_lua.bindClassStaticFunction("g_game", "talk", std::bind(&Game::talk, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "talk", &Game::talk, &g_game);
g_lua.bindClassStaticFunction("g_game", "talkChannel", std::bind(&Game::talkChannel, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_game", "talkChannel", &Game::talkChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "talkPrivate", std::bind(&Game::talkPrivate, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_game", "talkPrivate", &Game::talkPrivate, &g_game);
g_lua.bindClassStaticFunction("g_game", "openPrivateChannel", std::bind(&Game::openPrivateChannel, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "openPrivateChannel", &Game::openPrivateChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "requestChannels", std::bind(&Game::requestChannels, &g_game)); g_lua.bindSingletonFunction("g_game", "requestChannels", &Game::requestChannels, &g_game);
g_lua.bindClassStaticFunction("g_game", "joinChannel", std::bind(&Game::joinChannel, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "joinChannel", &Game::joinChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "leaveChannel", std::bind(&Game::leaveChannel, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "leaveChannel", &Game::leaveChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "closeNpcChannel", std::bind(&Game::closeNpcChannel, &g_game)); g_lua.bindSingletonFunction("g_game", "closeNpcChannel", &Game::closeNpcChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "openOwnChannel", std::bind(&Game::openOwnChannel, &g_game)); g_lua.bindSingletonFunction("g_game", "openOwnChannel", &Game::openOwnChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "inviteToOwnChannel", std::bind(&Game::inviteToOwnChannel, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "inviteToOwnChannel", &Game::inviteToOwnChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "excludeFromOwnChannel", std::bind(&Game::excludeFromOwnChannel, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "excludeFromOwnChannel", &Game::excludeFromOwnChannel, &g_game);
g_lua.bindClassStaticFunction("g_game", "partyInvite", std::bind(&Game::partyInvite, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "partyInvite", &Game::partyInvite, &g_game);
g_lua.bindClassStaticFunction("g_game", "partyJoin", std::bind(&Game::partyJoin, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "partyJoin", &Game::partyJoin, &g_game);
g_lua.bindClassStaticFunction("g_game", "partyRevokeInvitation", std::bind(&Game::partyRevokeInvitation, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "partyRevokeInvitation", &Game::partyRevokeInvitation, &g_game);
g_lua.bindClassStaticFunction("g_game", "partyPassLeadership", std::bind(&Game::partyPassLeadership, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "partyPassLeadership", &Game::partyPassLeadership, &g_game);
g_lua.bindClassStaticFunction("g_game", "partyLeave", std::bind(&Game::partyLeave, &g_game)); g_lua.bindSingletonFunction("g_game", "partyLeave", &Game::partyLeave, &g_game);
g_lua.bindClassStaticFunction("g_game", "partyShareExperience", std::bind(&Game::partyShareExperience, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "partyShareExperience", &Game::partyShareExperience, &g_game);
g_lua.bindClassStaticFunction("g_game", "requestOutfit", std::bind(&Game::requestOutfit, &g_game)); g_lua.bindSingletonFunction("g_game", "requestOutfit", &Game::requestOutfit, &g_game);
g_lua.bindClassStaticFunction("g_game", "changeOutfit", std::bind(&Game::changeOutfit, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "changeOutfit", &Game::changeOutfit, &g_game);
g_lua.bindClassStaticFunction("g_game", "addVip", std::bind(&Game::addVip, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "addVip", &Game::addVip, &g_game);
g_lua.bindClassStaticFunction("g_game", "removeVip", std::bind(&Game::removeVip, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "removeVip", &Game::removeVip, &g_game);
g_lua.bindClassStaticFunction("g_game", "setChaseMode", std::bind(&Game::setChaseMode, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "setChaseMode", &Game::setChaseMode, &g_game);
g_lua.bindClassStaticFunction("g_game", "setFightMode", std::bind(&Game::setFightMode, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "setFightMode", &Game::setFightMode, &g_game);
g_lua.bindClassStaticFunction("g_game", "setSafeFight", std::bind(&Game::setSafeFight, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "setSafeFight", &Game::setSafeFight, &g_game);
g_lua.bindClassStaticFunction("g_game", "getChaseMode", std::bind(&Game::getChaseMode, &g_game)); g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game);
g_lua.bindClassStaticFunction("g_game", "getFightMode", std::bind(&Game::getFightMode, &g_game)); g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game);
g_lua.bindClassStaticFunction("g_game", "isSafeFight", std::bind(&Game::isSafeFight, &g_game)); g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game);
g_lua.bindClassStaticFunction("g_game", "inspectNpcTrade", std::bind(&Game::inspectNpcTrade, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
g_lua.bindClassStaticFunction("g_game", "buyItem", std::bind(&Game::buyItem, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);
g_lua.bindClassStaticFunction("g_game", "sellItem", std::bind(&Game::sellItem, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_game", "sellItem", &Game::sellItem, &g_game);
g_lua.bindClassStaticFunction("g_game", "closeNpcTrade", std::bind(&Game::closeNpcTrade, &g_game)); g_lua.bindSingletonFunction("g_game", "closeNpcTrade", &Game::closeNpcTrade, &g_game);
g_lua.bindClassStaticFunction("g_game", "requestTrade", std::bind(&Game::requestTrade, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "requestTrade", &Game::requestTrade, &g_game);
g_lua.bindClassStaticFunction("g_game", "inspectTrade", std::bind(&Game::inspectTrade, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "inspectTrade", &Game::inspectTrade, &g_game);
g_lua.bindClassStaticFunction("g_game", "acceptTrade", std::bind(&Game::acceptTrade, &g_game)); g_lua.bindSingletonFunction("g_game", "acceptTrade", &Game::acceptTrade, &g_game);
g_lua.bindClassStaticFunction("g_game", "rejectTrade", std::bind(&Game::rejectTrade, &g_game)); g_lua.bindSingletonFunction("g_game", "rejectTrade", &Game::rejectTrade, &g_game);
g_lua.bindClassStaticFunction("g_game", "reportBug", std::bind(&Game::reportBug, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "reportBug", &Game::reportBug, &g_game);
g_lua.bindClassStaticFunction("g_game", "reportRuleVilation", std::bind(&Game::reportRuleVilation, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7)); g_lua.bindSingletonFunction("g_game", "reportRuleVilation", &Game::reportRuleVilation, &g_game);
g_lua.bindClassStaticFunction("g_game", "debugReport", std::bind(&Game::debugReport, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); g_lua.bindSingletonFunction("g_game", "debugReport", &Game::debugReport, &g_game);
g_lua.bindClassStaticFunction("g_game", "editText", std::bind(&Game::editText, &g_game, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_game", "editText", &Game::editText, &g_game);
g_lua.bindClassStaticFunction("g_game", "editList", std::bind(&Game::editList, &g_game, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); g_lua.bindSingletonFunction("g_game", "editList", &Game::editList, &g_game);
g_lua.bindClassStaticFunction("g_game", "requestQuestLog", std::bind(&Game::requestQuestLog, &g_game)); g_lua.bindSingletonFunction("g_game", "requestQuestLog", &Game::requestQuestLog, &g_game);
g_lua.bindClassStaticFunction("g_game", "requestQuestLine", std::bind(&Game::requestQuestLine, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "requestQuestLine", &Game::requestQuestLine, &g_game);
g_lua.bindClassStaticFunction("g_game", "equipItem", std::bind(&Game::equipItem, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "equipItem", &Game::equipItem, &g_game);
g_lua.bindClassStaticFunction("g_game", "mount", std::bind(&Game::mount, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "mount", &Game::mount, &g_game);
g_lua.bindClassStaticFunction("g_game", "canPerformGameAction", std::bind(&Game::canPerformGameAction, &g_game)); g_lua.bindSingletonFunction("g_game", "canPerformGameAction", &Game::canPerformGameAction, &g_game);
g_lua.bindClassStaticFunction("g_game", "canReportBugs", std::bind(&Game::canReportBugs, &g_game)); g_lua.bindSingletonFunction("g_game", "canReportBugs", &Game::canReportBugs, &g_game);
g_lua.bindClassStaticFunction("g_game", "checkBotProtection", std::bind(&Game::checkBotProtection, &g_game)); g_lua.bindSingletonFunction("g_game", "checkBotProtection", &Game::checkBotProtection, &g_game);
g_lua.bindClassStaticFunction("g_game", "isOnline", std::bind(&Game::isOnline, &g_game)); g_lua.bindSingletonFunction("g_game", "isOnline", &Game::isOnline, &g_game);
g_lua.bindClassStaticFunction("g_game", "isDead", std::bind(&Game::isDead, &g_game)); g_lua.bindSingletonFunction("g_game", "isDead", &Game::isDead, &g_game);
g_lua.bindClassStaticFunction("g_game", "isAttacking", std::bind(&Game::isAttacking, &g_game)); g_lua.bindSingletonFunction("g_game", "isAttacking", &Game::isAttacking, &g_game);
g_lua.bindClassStaticFunction("g_game", "isFollowing", std::bind(&Game::isFollowing, &g_game)); g_lua.bindSingletonFunction("g_game", "isFollowing", &Game::isFollowing, &g_game);
g_lua.bindClassStaticFunction("g_game", "getContainer", std::bind(&Game::getContainer, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "getContainer", &Game::getContainer, &g_game);
g_lua.bindClassStaticFunction("g_game", "getContainers", std::bind(&Game::getContainers, &g_game)); g_lua.bindSingletonFunction("g_game", "getContainers", &Game::getContainers, &g_game);
g_lua.bindClassStaticFunction("g_game", "getVips", std::bind(&Game::getVips, &g_game)); g_lua.bindSingletonFunction("g_game", "getVips", &Game::getVips, &g_game);
g_lua.bindClassStaticFunction("g_game", "getAttackingCreature", std::bind(&Game::getAttackingCreature, &g_game)); g_lua.bindSingletonFunction("g_game", "getAttackingCreature", &Game::getAttackingCreature, &g_game);
g_lua.bindClassStaticFunction("g_game", "getFollowingCreature", std::bind(&Game::getFollowingCreature, &g_game)); g_lua.bindSingletonFunction("g_game", "getFollowingCreature", &Game::getFollowingCreature, &g_game);
g_lua.bindClassStaticFunction("g_game", "getServerBeat", std::bind(&Game::getServerBeat, &g_game)); g_lua.bindSingletonFunction("g_game", "getServerBeat", &Game::getServerBeat, &g_game);
g_lua.bindClassStaticFunction("g_game", "getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); g_lua.bindSingletonFunction("g_game", "getLocalPlayer", &Game::getLocalPlayer, &g_game);
g_lua.bindClassStaticFunction("g_game", "getProtocolGame", std::bind(&Game::getProtocolGame, &g_game)); g_lua.bindSingletonFunction("g_game", "getProtocolGame", &Game::getProtocolGame, &g_game);
g_lua.bindClassStaticFunction("g_game", "getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game)); g_lua.bindSingletonFunction("g_game", "getProtocolVersion", &Game::getProtocolVersion, &g_game);
g_lua.bindClassStaticFunction("g_game", "getCharacterName", std::bind(&Game::getCharacterName, &g_game)); g_lua.bindSingletonFunction("g_game", "getCharacterName", &Game::getCharacterName, &g_game);
g_lua.bindClassStaticFunction("g_game", "getWorldName", std::bind(&Game::getWorldName, &g_game)); g_lua.bindSingletonFunction("g_game", "getWorldName", &Game::getWorldName, &g_game);
g_lua.bindClassStaticFunction("g_game", "getGMActions", std::bind(&Game::getGMActions, &g_game)); g_lua.bindSingletonFunction("g_game", "getGMActions", &Game::getGMActions, &g_game);
g_lua.bindClassStaticFunction("g_game", "getClientVersion", std::bind(&Game::getClientVersion, &g_game)); g_lua.bindSingletonFunction("g_game", "getClientVersion", &Game::getClientVersion, &g_game);
g_lua.bindClassStaticFunction("g_game", "getFeature", std::bind(&Game::getFeature, &g_game, std::placeholders::_1)); g_lua.bindSingletonFunction("g_game", "getFeature", &Game::getFeature, &g_game);
g_lua.registerStaticClass("g_shaders"); g_lua.registerSingletonClass("g_shaders");
g_lua.bindClassStaticFunction("g_shaders", "createShader", std::bind(&ShaderManager::createShader, &g_shaders, std::placeholders::_1)); g_lua.bindSingletonFunction("g_shaders", "createShader", &ShaderManager::createShader, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "createFragmentShader", std::bind(&ShaderManager::createFragmentShader, &g_shaders, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_shaders", "createFragmentShader", &ShaderManager::createFragmentShader, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "createFragmentShaderFromCode", std::bind(&ShaderManager::createFragmentShaderFromCode, &g_shaders, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_shaders", "createFragmentShaderFromCode", &ShaderManager::createFragmentShaderFromCode, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "createItemShader", std::bind(&ShaderManager::createItemShader, &g_shaders, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_shaders", "createItemShader", &ShaderManager::createItemShader, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "createMapShader", std::bind(&ShaderManager::createMapShader, &g_shaders, std::placeholders::_1, std::placeholders::_2)); g_lua.bindSingletonFunction("g_shaders", "createMapShader", &ShaderManager::createMapShader, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "getDefaultItemShader", std::bind(&ShaderManager::getDefaultItemShader, &g_shaders)); g_lua.bindSingletonFunction("g_shaders", "getDefaultItemShader", &ShaderManager::getDefaultItemShader, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "getDefaultMapShader", std::bind(&ShaderManager::getDefaultMapShader, &g_shaders)); g_lua.bindSingletonFunction("g_shaders", "getDefaultMapShader", &ShaderManager::getDefaultMapShader, &g_shaders);
g_lua.bindClassStaticFunction("g_shaders", "getShader", std::bind(&ShaderManager::getShader, &g_shaders, std::placeholders::_1)); g_lua.bindSingletonFunction("g_shaders", "getShader", &ShaderManager::getShader, &g_shaders);
g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor); g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor);