teek 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +139 -0
- data/Rakefile +316 -0
- data/ext/teek/extconf.rb +79 -0
- data/ext/teek/stubs.h +33 -0
- data/ext/teek/tcl9compat.h +211 -0
- data/ext/teek/tcltkbridge.c +1597 -0
- data/ext/teek/tcltkbridge.h +42 -0
- data/ext/teek/tkfont.c +218 -0
- data/ext/teek/tkphoto.c +477 -0
- data/ext/teek/tkwin.c +144 -0
- data/lib/teek/background_none.rb +158 -0
- data/lib/teek/background_ractor4x.rb +410 -0
- data/lib/teek/background_thread.rb +272 -0
- data/lib/teek/debugger.rb +742 -0
- data/lib/teek/demo_support.rb +150 -0
- data/lib/teek/ractor_support.rb +246 -0
- data/lib/teek/version.rb +5 -0
- data/lib/teek.rb +540 -0
- data/sample/calculator.rb +260 -0
- data/sample/debug_demo.rb +45 -0
- data/sample/goldberg.rb +1803 -0
- data/sample/goldberg_helpers.rb +170 -0
- data/sample/minesweeper/assets/MINESWEEPER_0.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_1.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_2.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_3.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_4.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_5.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_6.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_7.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_8.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_F.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_M.png +0 -0
- data/sample/minesweeper/assets/MINESWEEPER_X.png +0 -0
- data/sample/minesweeper/minesweeper.rb +452 -0
- data/sample/threading_demo.rb +499 -0
- data/teek.gemspec +32 -0
- metadata +179 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* tcl9compat.h - Tcl 8.x/9.x compatibility layer for Ruby/Tk
|
|
3
|
+
*
|
|
4
|
+
* This header provides compatibility definitions to allow the Ruby/Tk
|
|
5
|
+
* extension to compile against both Tcl 8.x and Tcl 9.x.
|
|
6
|
+
*
|
|
7
|
+
* Key changes in Tcl 9.0:
|
|
8
|
+
* - Tcl_Size replaces int for length/index parameters (supports 64-bit)
|
|
9
|
+
* - Tcl_UniChar is now 32-bit (was 16-bit on Windows)
|
|
10
|
+
* - CONST macro removed (use const directly)
|
|
11
|
+
* - Threading always enabled
|
|
12
|
+
* - Stubs ABI changes
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
#ifndef TCL9COMPAT_H
|
|
16
|
+
#define TCL9COMPAT_H
|
|
17
|
+
|
|
18
|
+
#include <tcl.h>
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* Tcl_Size compatibility
|
|
22
|
+
*
|
|
23
|
+
* Tcl 9.0 introduces Tcl_Size as a signed 64-bit type for sizes and indices.
|
|
24
|
+
* For Tcl 8.x, we define it as int for compatibility.
|
|
25
|
+
*/
|
|
26
|
+
#ifndef TCL_SIZE_MAX
|
|
27
|
+
/* Tcl 8.x does not have Tcl_Size, define it as int */
|
|
28
|
+
typedef int Tcl_Size;
|
|
29
|
+
#define TCL_SIZE_MAX INT_MAX
|
|
30
|
+
#define TCL_SIZE_MODIFIER ""
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* CONST/CONST84/CONST86 compatibility
|
|
35
|
+
*
|
|
36
|
+
* Tcl 9.0 removes the CONST macro. All code should use standard 'const'.
|
|
37
|
+
* For compatibility with older Tcl versions, we ensure these are defined.
|
|
38
|
+
*/
|
|
39
|
+
#ifndef CONST
|
|
40
|
+
#define CONST const
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
/* CONST84/CONST86 are always const for Tcl 8.6+ */
|
|
44
|
+
#ifndef CONST84
|
|
45
|
+
#define CONST84 const
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
#ifndef CONST86
|
|
49
|
+
#define CONST86 const
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
* Command procedure type compatibility
|
|
54
|
+
*
|
|
55
|
+
* Tcl 9.0 uses Tcl_Size for objc parameter in command procedures.
|
|
56
|
+
* We provide a wrapper macro to handle both versions.
|
|
57
|
+
*/
|
|
58
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
59
|
+
#define RBTK_OBJC_TYPE Tcl_Size
|
|
60
|
+
#else
|
|
61
|
+
#define RBTK_OBJC_TYPE int
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* String length type for Tcl API calls
|
|
66
|
+
*
|
|
67
|
+
* Tcl 9.0 uses Tcl_Size* for length parameters in functions like
|
|
68
|
+
* Tcl_GetStringFromObj(). We provide a type alias.
|
|
69
|
+
*/
|
|
70
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
71
|
+
#define RBTK_STRLEN_TYPE Tcl_Size
|
|
72
|
+
#else
|
|
73
|
+
#define RBTK_STRLEN_TYPE int
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* NULL pointer for length parameters when caller doesn't need the length.
|
|
78
|
+
*
|
|
79
|
+
* Many Tcl functions like Tcl_GetStringFromObj() take an optional length
|
|
80
|
+
* output parameter. When you don't need the length, pass NULL. This macro
|
|
81
|
+
* provides the correctly-typed NULL for the Tcl version being compiled against.
|
|
82
|
+
*
|
|
83
|
+
* Usage:
|
|
84
|
+
* str = Tcl_GetStringFromObj(obj, TCL_SIZE_NULL); // don't need length
|
|
85
|
+
* str = Tcl_GetStringFromObj(obj, &len); // need length (len is Tcl_Size)
|
|
86
|
+
*/
|
|
87
|
+
#define TCL_SIZE_NULL ((Tcl_Size*)NULL)
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* Tcl_UniChar compatibility
|
|
91
|
+
*
|
|
92
|
+
* Tcl 9.0 makes Tcl_UniChar always 32-bit (int).
|
|
93
|
+
* Previously it was 16-bit on Windows.
|
|
94
|
+
* This shouldn't require code changes in most cases, but we provide
|
|
95
|
+
* a check macro for code that needs to handle it specially.
|
|
96
|
+
*/
|
|
97
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
98
|
+
#define RBTK_UNICHAR_IS_32BIT 1
|
|
99
|
+
#else
|
|
100
|
+
#ifdef _WIN32
|
|
101
|
+
#define RBTK_UNICHAR_IS_32BIT 0
|
|
102
|
+
#else
|
|
103
|
+
#define RBTK_UNICHAR_IS_32BIT 1
|
|
104
|
+
#endif
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* Stubs version compatibility
|
|
109
|
+
*
|
|
110
|
+
* The minimum stubs version should be set appropriately.
|
|
111
|
+
* For Tcl 9.0+, we need at least 8.6 stubs (the last 8.x version).
|
|
112
|
+
*/
|
|
113
|
+
/* Require at least 8.6 stubs (minimum supported version) */
|
|
114
|
+
#define RBTK_TCL_STUBS_VERSION "8.6"
|
|
115
|
+
#define RBTK_TK_STUBS_VERSION "8.6"
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Deprecated API compatibility wrappers
|
|
119
|
+
*
|
|
120
|
+
* Some Tcl 8.x APIs are deprecated or changed in 9.0.
|
|
121
|
+
* We provide compatibility where needed.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* Tcl_GetStringResult is deprecated in 9.0 but still works.
|
|
126
|
+
* New code should use Tcl_GetObjResult() instead.
|
|
127
|
+
*/
|
|
128
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
129
|
+
/* Use the existing function, it's still available */
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* Tcl_AppendResult is deprecated in 9.0.
|
|
134
|
+
* New code should use Tcl_AppendObjToObj() or Tcl_SetObjResult().
|
|
135
|
+
* For now, the function still works, so no wrapper needed.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* TCL_INTERP_DESTROYED compatibility (TIP 543)
|
|
140
|
+
*
|
|
141
|
+
* Tcl 9.0 removes the TCL_INTERP_DESTROYED flag entirely.
|
|
142
|
+
* Code should use Tcl_InterpDeleted() instead (available since Tcl 7.5).
|
|
143
|
+
*
|
|
144
|
+
* For variable trace callbacks that check this flag, we provide a macro
|
|
145
|
+
* that checks using Tcl_InterpDeleted() on Tcl 9.x.
|
|
146
|
+
*
|
|
147
|
+
* Note: The callback receives flags and interp, so we pass interp as param.
|
|
148
|
+
*/
|
|
149
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
150
|
+
#define RBTK_INTERP_DESTROYED(interp, flags) Tcl_InterpDeleted(interp)
|
|
151
|
+
#else
|
|
152
|
+
#define RBTK_INTERP_DESTROYED(interp, flags) ((flags) & TCL_INTERP_DESTROYED)
|
|
153
|
+
#endif
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
* Tk_Preserve/Tk_Release compatibility
|
|
157
|
+
*
|
|
158
|
+
* These Tk functions were deprecated and removed in favor of the
|
|
159
|
+
* equivalent Tcl functions: Tcl_Preserve/Tcl_Release.
|
|
160
|
+
* The Tcl versions have been available since Tcl 7.5.
|
|
161
|
+
*/
|
|
162
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
163
|
+
#define RbTk_Preserve(clientData) Tcl_Preserve(clientData)
|
|
164
|
+
#define RbTk_Release(clientData) Tcl_Release(clientData)
|
|
165
|
+
#else
|
|
166
|
+
/* On Tcl 8.x, use Tk versions if available, otherwise Tcl versions */
|
|
167
|
+
#ifdef Tk_Preserve
|
|
168
|
+
#define RbTk_Preserve(clientData) Tk_Preserve(clientData)
|
|
169
|
+
#define RbTk_Release(clientData) Tk_Release(clientData)
|
|
170
|
+
#else
|
|
171
|
+
#define RbTk_Preserve(clientData) Tcl_Preserve(clientData)
|
|
172
|
+
#define RbTk_Release(clientData) Tcl_Release(clientData)
|
|
173
|
+
#endif
|
|
174
|
+
#endif
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
* Tcl_MakeSafe compatibility (TIP 624)
|
|
178
|
+
* https://core.tcl-lang.org/tips/doc/trunk/tip/624.md
|
|
179
|
+
*
|
|
180
|
+
* Tcl_MakeSafe() was removed in Tcl 9.0.
|
|
181
|
+
* In Tcl 9, safe interpreters must be created safe from the start
|
|
182
|
+
* using Tcl_CreateSlave with the safe flag, or Tcl_CreateInterp
|
|
183
|
+
* followed by safe initialization. An existing interpreter cannot
|
|
184
|
+
* be converted to safe mode.
|
|
185
|
+
*
|
|
186
|
+
* We provide a compatibility macro that returns TCL_ERROR on Tcl 9.
|
|
187
|
+
*/
|
|
188
|
+
#if TCL_MAJOR_VERSION >= 9
|
|
189
|
+
#define RBTK_HAS_MAKE_SAFE 0
|
|
190
|
+
#define RbTk_MakeSafe(interp) \
|
|
191
|
+
(Tcl_SetObjResult((interp), Tcl_NewStringObj("Tcl_MakeSafe not available in Tcl 9.x", -1)), TCL_ERROR)
|
|
192
|
+
#else
|
|
193
|
+
#define RBTK_HAS_MAKE_SAFE 1
|
|
194
|
+
#define RbTk_MakeSafe(interp) Tcl_MakeSafe(interp)
|
|
195
|
+
#endif
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
* Version detection macros
|
|
199
|
+
*/
|
|
200
|
+
#define RBTK_TCL_VERSION_GE(major, minor) \
|
|
201
|
+
(TCL_MAJOR_VERSION > (major) || \
|
|
202
|
+
(TCL_MAJOR_VERSION == (major) && TCL_MINOR_VERSION >= (minor)))
|
|
203
|
+
|
|
204
|
+
#define RBTK_TCL_VERSION_LT(major, minor) \
|
|
205
|
+
(TCL_MAJOR_VERSION < (major) || \
|
|
206
|
+
(TCL_MAJOR_VERSION == (major) && TCL_MINOR_VERSION < (minor)))
|
|
207
|
+
|
|
208
|
+
#define RBTK_IS_TCL9 (TCL_MAJOR_VERSION >= 9)
|
|
209
|
+
#define RBTK_IS_TCL8 (TCL_MAJOR_VERSION == 8)
|
|
210
|
+
|
|
211
|
+
#endif /* TCL9COMPAT_H */
|