Introduced window registry and changed win/plot weak table to ordinary. - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/lua-plot.cpp
diff options
context:
space:
mode:
authorfrancesco-ST <francesco.abbate@st.com>2011年02月03日 15:56:02 +0100
committerfrancesco-ST <francesco.abbate@st.com>2011年02月03日 15:56:02 +0100
commitf9f49265522fe933fd6ca726ecd23bf33c9aae09 (patch)
tree59a12e3870bca9379cd99adf673ce0aa6536656e /agg-plot/lua-plot.cpp
parent9cd1461d668ec3c38700a5a88fc9bd1fd9b79cc3 (diff)
downloadgsl-shell-f9f49265522fe933fd6ca726ecd23bf33c9aae09.tar.gz
Introduced window registry and changed win/plot weak table to ordinary.
Now the table that store the window <-> plot relations is no more weak on the keys (windows). The windows are removed from the table when the event loop thread of the windows terminates. In this way we don't depend on the GC and we avoid the problems with delayed removal of the keys.
Diffstat (limited to 'agg-plot/lua-plot.cpp')
-rw-r--r--agg-plot/lua-plot.cpp 37
1 files changed, 31 insertions, 6 deletions
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp
index c3122a2d..9bb9eda3 100644
--- a/agg-plot/lua-plot.cpp
+++ b/agg-plot/lua-plot.cpp
@@ -30,7 +30,7 @@ extern "C" {
#include "window.h"
#include "gs-types.h"
#include "lua-utils.h"
-#include "object-refs.h"
+#include "window_registry.h"
#include "lua-cpp-utils.h"
#include "lua-draw.h"
#include "colors.h"
@@ -176,6 +176,31 @@ plot_add_gener_cpp (lua_State *L, lua_plot *p, bool as_line,
}
}
+static void
+objref_mref_add (lua_State *L, int table_index, int index, int value_index)
+{
+ int n;
+ INDEX_SET_ABS(L, table_index);
+
+ lua_rawgeti (L, table_index, index);
+ if (lua_isnil (L, -1))
+ {
+ lua_pop (L, 1);
+ lua_newtable (L);
+ lua_pushvalue (L, -1);
+ lua_rawseti (L, table_index, index);
+ n = 0;
+ }
+ else
+ {
+ n = lua_objlen (L, -1);
+ }
+
+ lua_pushvalue (L, value_index);
+ lua_rawseti (L, -2, n+1);
+ lua_pop (L, 1);
+}
+
int
plot_add_gener (lua_State *L, bool as_line)
{
@@ -277,7 +302,7 @@ plot_newindex (lua_State *L)
void
plot_update_raw (lua_State *L, lua_plot *p, int plot_index)
{
- object_refs_lookup_apply (L, table_window_plot, plot_index, window_slot_update);
+ window_refs_lookup_apply (L, plot_index, window_slot_update);
p->commit_pending_draw();
}
@@ -293,7 +318,7 @@ int
plot_flush (lua_State *L)
{
lua_plot *p = object_check<lua_plot>(L, 1, GS_PLOT);
- object_refs_lookup_apply (L, table_window_plot, 1, window_slot_refresh);
+ window_refs_lookup_apply (L, 1, window_slot_refresh);
p->commit_pending_draw();
return 0;
}
@@ -332,13 +357,13 @@ plot_push_layer (lua_State *L)
{
lua_plot *p = object_check<lua_plot>(L, 1, GS_PLOT);
- object_refs_lookup_apply (L, table_window_plot, 1, window_slot_refresh);
+ window_refs_lookup_apply (L, 1, window_slot_refresh);
AGG_LOCK();
p->push_layer();
AGG_UNLOCK();
- object_refs_lookup_apply (L, table_window_plot, 1, window_save_slot_image);
+ window_refs_lookup_apply (L, 1, window_save_slot_image);
return 0;
}
@@ -378,7 +403,7 @@ plot_clear (lua_State *L)
p->clear_current_layer();
AGG_UNLOCK();
- object_refs_lookup_apply (L, table_window_plot, 1, window_restore_slot_image);
+ window_refs_lookup_apply (L, 1, window_restore_slot_image);
if (p->sync_mode())
plot_update_raw (L, p, 1);
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月14日 14:21:21 +0000

AltStyle によって変換されたページ (->オリジナル) /