Skip to content

Commit d920491

Browse files
committed
CHANGE: replacing some context usage with construct or object
related to: Oldes/Rebol-issues#2123 and Oldes/Rebol-issues#2118
1 parent 0ee9ee9 commit d920491

12 files changed

+65
-96
lines changed

src/boot/natives.reb

+3-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ compose: native [
9696
out [any-block!]
9797
]
9898

99-
context: native [
99+
object: native [
100100
{Creates an object.}
101-
spec ; [block!] -- no check required, we know it is correct
101+
spec [block!]
102+
/only {Do not bind nested blocks}
102103
]
103104

104105
continue: native [

src/boot/sysobj.reb

+45-62
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ Licensed under the Apache License, Version 2.0.
2929
See: http://www.apache.org/licenses/LICENSE-2.0
3030
}
3131

32-
catalog: context [
32+
catalog: object [
3333
; Static (non-changing) values, blocks, objects
3434
datatypes: []
3535
actions: none
3636
natives: none
37-
errors: none
37+
errors: none
3838
; Reflectors are used on boot to create *-of functions
3939
reflectors: [
4040
spec [any-function! any-object! vector! datatype!]
@@ -51,7 +51,7 @@ catalog: context [
5151
help vers quiet verbose
5252
secure-min secure-max trace halt cgi boot-level no-window
5353
]
54-
bitsets: context [
54+
bitsets: object [
5555
crlf: #[bitset! #{0024}] ;charset "^/^M"
5656
whitespace: #[bitset! #{0064000080}] ;charset "^/^M^- "
5757
numeric: #[bitset! #{000000000000FFC0}] ;0-9
@@ -64,18 +64,17 @@ catalog: context [
6464
]
6565
]
6666

67-
contexts: context [
67+
contexts: construct [
6868
root:
6969
sys:
7070
lib:
7171
user:
72-
none
7372
]
7473

75-
state: context [
74+
state: object [
7675
; Mutable system state variables
7776
note: "contains protected hidden fields"
78-
policies: context [ ; Security policies
77+
policies: construct [ ; Security policies
7978
file: ; file access
8079
net: ; network access
8180
eval: ; evaluation limit
@@ -94,20 +93,19 @@ state: context [
9493

9594
modules: []
9695

97-
codecs: context []
96+
codecs: object []
9897

99-
dialects: context [
98+
dialects: construct [
10099
secure:
101100
draw:
102101
effect:
103102
text:
104103
rebcode:
105-
none
106104
]
107105

108-
schemes: context []
106+
schemes: object []
109107

110-
ports: context [
108+
ports: object [
111109
wait-list: [] ; List of ports to add to 'wait
112110
input: ; Port for user input.
113111
output: ; Port for user output
@@ -117,7 +115,7 @@ ports: context [
117115
; serial: none ; serial device name block
118116
]
119117

120-
locale: context [
118+
locale: object [
121119
language: ; Human language locale
122120
language*:
123121
locale:
@@ -131,7 +129,7 @@ locale: context [
131129
]
132130
]
133131

134-
options: context [ ; Options supplied to REBOL during startup
132+
options: object [ ; Options supplied to REBOL during startup
135133
boot: ; The path to the executable
136134
path: ; Where script was started or the startup dir
137135
home: ; Path of home directory
@@ -159,59 +157,55 @@ options: context [ ; Options supplied to REBOL during startup
159157

160158
; verbosity of logs per service (codecs, schemes)
161159
; 0 = nothing; 1 = info; 2 = more; 3 = debug
162-
log: make object! [
160+
log: construct [
163161
http:
164162
tls:
165163
zip:
166164
tar: 1
167165
]
168166
]
169167

170-
script: context [
168+
script: construct [
171169
title: ; Title string of script
172170
header: ; Script header as evaluated
173171
parent: ; Script that loaded the current one
174172
path: ; Location of the script being evaluated
175173
args: ; args passed to script
176-
none
177174
]
178175

179-
standard: context [
176+
standard: object [
180177

181-
codec: context [
178+
codec: construct [
182179
name: ;word!
183180
title: ;string!
184181
suffixes: ;block!
185182
decode: ;[any-function! none!]
186183
encode: ;[any-function! none!]
187184
identify: ;[any-function! none!]
188-
none
189185
]
190186

191187
enum: none ; is defined later in %mezz-func.r file
192188

193-
error: context [ ; Template used for all errors:
189+
error: construct [ ; Template used for all errors:
194190
code: 0
195-
type: 'user
196-
id: 'message
191+
type: user
192+
id: message
197193
arg1:
198194
arg2:
199195
arg3:
200196
near:
201197
where:
202-
none
203198
]
204199

205-
script: context [
200+
script: construct [
206201
title:
207202
header:
208203
parent:
209204
path:
210205
args:
211-
none
212206
]
213207

214-
header: context [
208+
header: construct [
215209
title: {Untitled}
216210
name:
217211
type:
@@ -225,10 +219,9 @@ standard: context [
225219
; compress:
226220
; exports:
227221
; content:
228-
none
229222
]
230223

231-
scheme: context [
224+
scheme: construct [
232225
name: ; word of http, ftp, sound, etc.
233226
title: ; user-friendly title for the scheme
234227
spec: ; custom spec for scheme (if needed)
@@ -237,10 +230,9 @@ standard: context [
237230
; type: ; bytes, integers, objects, values, block
238231
actor: ; standard action handler for scheme port functions
239232
awake: ; standard awake handler for this scheme's ports
240-
none
241233
]
242234

243-
port: context [ ; Port specification object
235+
port: construct [ ; Port specification object
244236
spec: ; published specification of the port
245237
scheme: ; scheme object used for this port
246238
actor: ; port action handler (script driven)
@@ -249,14 +241,13 @@ standard: context [
249241
data: ; data buffer (usually binary or block)
250242
locals: ; user-defined storage of local data
251243
; stats: ; stats on operation (optional)
252-
none
253244
]
254245

255-
port-spec-head: context [
246+
port-spec-head: construct [
256247
title: ; user-friendly title for port
257248
scheme: ; reference to scheme that defines this port
258249
ref: ; reference path or url (for errors)
259-
none ; (extended here)
250+
; (extended here)
260251
]
261252

262253
port-spec-file: make port-spec-head [
@@ -279,38 +270,35 @@ standard: context [
279270
device-out: none
280271
]
281272

282-
file-info: context [
273+
file-info: construct [
283274
name:
284275
size:
285276
date:
286277
type:
287-
none
288278
]
289279

290-
net-info: context [
280+
net-info: construct [
291281
local-ip:
292282
local-port:
293283
remote-ip:
294284
remote-port:
295-
none
296285
]
297286

298-
console-info: context [
299-
buffer-cols: none
300-
buffer-rows: none
301-
window-cols: none
302-
window-rows: none
287+
console-info: construct [
288+
buffer-cols:
289+
buffer-rows:
290+
window-cols:
291+
window-rows:
303292
]
304293

305-
vector-info: context [
294+
vector-info: construct [
306295
signed: ; false if unsigned (always true for decimals)
307296
type: ; integer! or decimal! so far
308297
size: ; size per value in bits
309298
length: ; number of values
310-
none
311299
]
312300

313-
date-info: context [
301+
date-info: construct [
314302
year:
315303
month:
316304
day:
@@ -327,26 +315,23 @@ standard: context [
327315
;isoweek:
328316
utc:
329317
julian:
330-
none
331318
]
332319

333-
midi-info: context [
320+
midi-info: construct [
334321
devices-in:
335322
devices-out:
336-
none
337323
]
338324

339-
extension: context [
325+
extension: construct [
340326
lib-base: ; handle to DLL
341327
lib-file: ; file name loaded
342328
lib-boot: ; module header and body
343329
command: ; command function
344330
cmd-index: ; command index counter
345331
words: ; symbol references
346-
none
347332
]
348333

349-
stats: context [ ; port stats
334+
stats: construct [ ; port stats
350335
timer: ; timer (nanos)
351336
evals: ; evaluations
352337
eval-natives:
@@ -359,13 +344,11 @@ standard: context [
359344
made-blocks:
360345
made-objects:
361346
recycles:
362-
none
363347
]
364348

365-
type-spec: context [
349+
type-spec: construct [
366350
title:
367351
type:
368-
none
369352
]
370353

371354
bincode: none
@@ -374,16 +357,16 @@ standard: context [
374357
para: none ; mezz-graphics.h
375358
]
376359

377-
view: context [
360+
view: object [
378361
screen-gob: none
379362
handler: none
380363
event-port: none
381-
metrics: context [
382-
screen-size: 0x0
383-
border-size: 0x0
384-
border-fixed: 0x0
385-
title-size: 0x0
386-
work-origin: 0x0
364+
metrics: construct [
365+
screen-size:
366+
border-size:
367+
border-fixed:
368+
title-size:
369+
work-origin:
387370
work-size: 0x0
388371
]
389372
event-types: [

src/core/b-init.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ extern const REBYTE Str_Banner[];
337337

338338
/***********************************************************************
339339
**
340-
*/ REBNATIVE(context)
340+
*/ REBNATIVE(object)
341341
/*
342342
** The spec block has already been bound to Lib_Context, to
343343
** allow any embedded values and functions to evaluate.
@@ -347,7 +347,7 @@ extern const REBYTE Str_Banner[];
347347
REBVAL *spec = D_ARG(1);
348348

349349
SET_OBJECT(ds, Make_Object(0, VAL_BLK(spec)));
350-
Bind_Block(VAL_OBJ_FRAME(ds), VAL_BLK(spec), BIND_ONLY); // not deep
350+
Bind_Block(VAL_OBJ_FRAME(ds), VAL_BLK(spec), D_REF(2)?BIND_ONLY:BIND_DEEP); // not deep
351351
Do_Blk(VAL_SERIES(spec), 0); // result ignored
352352
return R_RET;
353353
}

src/mezz/base-funcs.reb

-7
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ use: func [
7070
apply make closure! reduce [to block! vars copy/deep body] []
7171
]
7272

73-
object: func [
74-
{Defines a unique object.}
75-
blk [block!] {Object words and values (modified)}
76-
][
77-
make object! blk ; blk modified by deep-binding
78-
]
79-
8073
module: func [
8174
"Creates a new module."
8275
spec [block!] "The header block of the module (modified)"

src/mezz/dial-draw.reb

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ REBOL [
1212
Note: "Modification requires recompiling affected source files."
1313
]
1414

15-
system/dialects/draw: context [
15+
system/dialects/draw: construct [
1616

1717
type-spec: [block!]
1818

@@ -121,5 +121,4 @@ system/dialects/draw: context [
121121

122122
;TEXT
123123
vectorial:
124-
none
125124
]

src/mezz/dial-effect.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ REBOL [
1212
Note: "Modification requires recompiling affected source files."
1313
]
1414

15-
system/dialects/effect: context [
15+
system/dialects/effect: construct [
1616

1717
type-spec: []
1818

0 commit comments

Comments
 (0)