win-plot-refs.c - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/win-plot-refs.c
blob: bd7a642a25655fea5f67234c8cbd07cf2c9269e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

#include <lua.h>
#include <lauxlib.h>
#include "lua-defs.h"
#include "refs.h"
#include "win-plot-refs.h"
static char const * const window_plot_ref_table_name = "GSL.winpltrefs";
void
window_plot_ref_prepare (lua_State *L)
{
 register_ref_table (L, window_plot_ref_table_name);
}
void
window_plot_ref_add (lua_State *L, int slot_id, int window_index, int plot_index)
{
 INDEX_SET_ABS_2(L, window_index, plot_index);
 lua_getfield (L, LUA_REGISTRYINDEX, window_plot_ref_table_name);
 lua_pushvalue (L, window_index);
 lua_rawget (L, -2);
 if (lua_isnil (L, -1))
 {
 lua_pop (L, 1);
 lua_newtable (L);
 lua_pushvalue (L, plot_index);
 lua_rawseti (L, -2, slot_id);
 lua_pushvalue (L, window_index);
 lua_insert (L, -2);
 lua_rawset (L, -3);
 }
 else
 {
 lua_pushvalue (L, plot_index);
 lua_rawseti (L, -2, slot_id);
 }
 lua_pop (L, 2);
}
void
window_plot_ref_remove (lua_State *L, int slot_id, int window_index)
{
 INDEX_SET_ABS(L, window_index);
 lua_getfield (L, LUA_REGISTRYINDEX, window_plot_ref_table_name);
 lua_pushvalue (L, window_index);
 lua_rawget (L, -2);
 if (! lua_isnil (L, -1))
 {
 lua_pushnil (L);
 lua_rawseti (L, -2, slot_id);
 }
 lua_pop (L, 2);
}
void
window_plot_rev_lookup_apply (lua_State *L, int plot_index, lua_CFunction func)
{
 INDEX_SET_ABS(L, plot_index);
 lua_getfield (L, LUA_REGISTRYINDEX, window_plot_ref_table_name);
 lua_pushnil (L);
 while (lua_next (L, -2) != 0)
 {
 lua_pushnil (L);
 while (lua_next (L, -2) != 0)
	{
	 if (lua_rawequal (L, -1, plot_index))
	 {
	 lua_pushcfunction (L, func);
	 lua_pushvalue (L, -5);
	 lua_pushvalue (L, -4);
	 lua_call (L, 2, 0);
	 }
	 lua_pop (L, 1);
	}
 lua_pop (L, 1);
 }
 lua_pop (L, 1);
}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月27日 17:44:46 +0000

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