From 14709e5d4598e11ddce6f9d2cce734528d842ca5 Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
Date: Sun, 15 Apr 2012 19:09:25 +0400
Subject: [PATCH] Add an official core lua context, and allow plugins to send
events to it.
- This context requires core suspend lock and asserts it in a few places.
- Special 'event' objects are introduced. They can be invoked as
functions, in which case they iterate all their fields and call
them as functions. Errors are printed and consumed.
- When a plugin is opened by the core context, events registered in
a special array are linked to it. The system is organized so as to
avoid even trying to pass the event to lua if the module isn't loaded.
---
LUA_API.rst | 14 ++
Lua API.html | 13 ++
library/Core.cpp | 17 ++
library/LuaApi.cpp | 45 ++----
library/LuaTools.cpp | 270 +++++++++++++++++++++++++++++++-
library/LuaTypes.cpp | 18 ++-
library/PluginManager.cpp | 60 +++++--
library/include/Core.h | 2 +
library/include/DataFuncs.h | 8 +-
library/include/DataIdentity.h | 6 +-
library/include/LuaTools.h | 174 +++++++++++++++++++-
library/include/LuaWrapper.h | 6 +
library/include/PluginManager.h | 23 ++-
library/lua/dfhack.lua | 4 +
plugins/Dfusion/dfusion.cpp | 7 +
plugins/burrows.cpp | 28 +++-
16 files changed, 632 insertions(+), 63 deletions(-)
diff --git a/LUA_API.rst b/LUA_API.rst
index d5af5e7a4..e68a87a66 100644
--- a/LUA_API.rst
+++ b/LUA_API.rst
@@ -799,3 +799,17 @@ Maps module
* ``dfhack.maps.setBlockBurrowTile(burrow,block,x,y,enable)``
Adds or removes the tile from the burrow. Returns *false* if invalid coords.
+
+
+Core interpreter context
+========================
+
+While plugins can create any number of interpreter instances,
+there is one special context managed by dfhack core. It is the
+only context that can receive events from DF and plugins.
+
+Core context specific functions:
+
+* ``dfhack.is_core_context``
+
+ Boolean value; *true* in the core context.
diff --git a/Lua API.html b/Lua API.html
index 66385840b..38a375d86 100644
--- a/Lua API.html
+++ b/Lua API.html
@@ -344,6 +344,7 @@ ul.auto-toc {
Maps module
+Core interpreter context
@@ -1010,6 +1011,18 @@ Returns false in case of error.
+
+
+
While plugins can create any number of interpreter instances,
+there is one special context managed by dfhack core. It is the
+only context that can receive events from DF and plugins.
+
Core context specific functions:
+
+