Skip to content

Commit f27939c

Browse files
committed
FEAT: define codec's types
1 parent 53167c3 commit f27939c

21 files changed

+44
-37
lines changed

src/boot/sysobj.reb

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ standard: object [
176176

177177
codec: construct [
178178
name: ;word!
179+
type: ;word!
179180
title: ;string!
180181
suffixes: ;block!
181182
decode: ;[any-function! none!]

src/mezz/base-defs.reb

+9-5
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ decode-url: none ; set in sys init
5151

5252
foreach [codec handler] system/codecs [
5353
if handle? handler [
54-
; Change boot handle into object:
55-
codec: set codec make object! [
56-
entry: handler
57-
title: form reduce ["Internal codec for" codec "media type"]
54+
; Change boot handle (for internal native codecs) into object:
55+
codec: set codec make object! [
5856
name: codec
59-
type: 'image!
57+
type: switch codec [
58+
text markup ['text ]
59+
gif bmp jpeg png ['image]
60+
wav ['sound]
61+
]
62+
title: form reduce ["Internal codec for" codec "media type"]
6063
suffixes: select [
6164
text [%.txt]
6265
markup [%.html %.htm %.xsl %.wml %.sgml %.asp %.php %.cgi]
6366
] codec
67+
entry: handler
6468
]
6569
; Media-types block format: [.abc .def type ...]
6670
if codec/suffixes [ ;append to file-types only if there is any suffix

src/mezz/codec-bbcode.reb

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ bbcode: func [
427427

428428
register-codec [
429429
name: 'bbcode
430+
type: 'text
430431
title: "Bulletin Board Code"
431432
suffixes: [%.bbcode]
432433

src/mezz/codec-crt.reb

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ REBOL [
77

88
register-codec [
99
name: 'crt
10+
type: 'cryptography
1011
title: "Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile"
1112
suffixes: [%.crt]
1213
decode: wrap [

src/mezz/codec-der.reb

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ REBOL [
1818

1919
register-codec [
2020
name: 'der
21+
type: 'cryptography
2122
title: "Distinguished Encoding Rules"
2223
suffixes: [%.p12 %.pfx %.cer %.der %.jks]
2324
decode: function[data [binary!]][
@@ -332,6 +333,7 @@ register-codec [
332333

333334
register-codec [
334335
name: 'mobileprovision
336+
type: 'cryptography
335337
title: "Apple's mobileprovision file"
336338
suffixes: [%.mobileprovision]
337339
decode: function[data [binary!]][

src/mezz/codec-gzip.reb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ REBOL [
88

99
register-codec [
1010
name: 'gzip
11+
type: 'compression
1112
title: "Lossless compressed data format compatible with GZIP utility."
1213
suffixes: [%.gz]
1314
decode: function[data [binary!]] [

src/mezz/codec-html-entities.reb

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ digits: charset [#"0" - #"9"]
278278

279279
register-codec [
280280
name: 'html-entities
281+
type: 'text
281282
title: "Reserved characters in HTML"
282283

283284
decode: func [

src/mezz/codec-ico.reb

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ REBOL [
99
system/options/log/ico: 2
1010
register-codec [
1111
name: 'ico
12+
type: 'image
1213
title: "Windows icon or cursor file"
1314
suffixes: [%.ico %.cur]
1415

src/mezz/codec-image-osx.reb

+8-16
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ REBOL [
1212

1313
register-codec [
1414
name: 'heif
15+
type: 'image
1516
title: "High Efficiency Image File Format"
1617
suffixes: [%.heif %.heic]
1718

@@ -22,6 +23,7 @@ register-codec [
2223

2324
register-codec [
2425
name: 'dds
26+
type: 'image
2527
title: "DirectDraw Surface"
2628
suffixes: [%.dds]
2729

@@ -32,6 +34,7 @@ register-codec [
3234

3335
register-codec [
3436
name: 'tiff
37+
type: 'image
3538
title: "Tagged Image File Format"
3639
suffixes: [%.tif %.tiff]
3740

@@ -42,6 +45,7 @@ register-codec [
4245

4346
register-codec [
4447
name: 'gif
48+
type: 'image
4549
title: "Graphics Interchange Format"
4650
suffixes: [%.gif]
4751

@@ -52,6 +56,7 @@ register-codec [
5256

5357
register-codec [
5458
name: 'bmp
59+
type: 'image
5560
title: "Portable Bitmap"
5661
suffixes: [%.bmp]
5762

@@ -62,6 +67,7 @@ register-codec [
6267

6368
register-codec [
6469
name: 'jpeg2000
70+
type: 'image
6571
title: "JPEG 2000"
6672
suffixes: [%.jp2 %.j2k %.jpf %.jpm %.jpg2 %.j2c %.jpc %.jpx %.mj2]
6773

@@ -72,6 +78,7 @@ register-codec [
7278

7379
register-codec [
7480
name: 'jpeg
81+
type: 'image
7582
title: "Joint Photographic Experts Group"
7683
suffixes: [%.jpg %.jpeg]
7784

@@ -82,26 +89,11 @@ register-codec [
8289

8390
register-codec [
8491
name: 'png
92+
type: 'image
8593
title: "Portable Network Graphics"
8694
suffixes: [%.png]
8795

8896
decode: func [data [binary!]][lib/image/load/as data 'PNG]
8997
encode: func [data [image! ]][lib/image/save/as none data 'PNG]
9098
identify: func [data [binary!]][parse data [#{89504E47} to end]]
9199
]
92-
93-
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-
107-

src/mezz/codec-image-win.reb

+8-16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ REBOL [
1414
register-codec [
1515
name: 'dng
1616
title: "Digital Negative"
17+
type: 'image
1718
suffixes: [%.dng]
1819
comment: {Decodes only thumbnail, not RAW data!}
1920

@@ -25,6 +26,7 @@ register-codec [
2526
register-codec [
2627
name: 'dds
2728
title: "DirectDraw Surface"
29+
type: 'image
2830
suffixes: [%.dds]
2931

3032
decode: func [data [binary!]][lib/image/load/as data 'DDS]
@@ -35,6 +37,7 @@ register-codec [
3537
register-codec [
3638
name: 'tiff
3739
title: "Tagged Image File Format"
40+
type: 'image
3841
suffixes: [%.tif %.tiff]
3942

4043
decode: func [data [binary!]][lib/image/load/as data 'TIFF]
@@ -45,6 +48,7 @@ register-codec [
4548
register-codec [
4649
name: 'gif
4750
title: "Graphics Interchange Format"
51+
type: 'image
4852
suffixes: [%.gif]
4953

5054
decode: func [data [binary!]][lib/image/load/as data 'GIF]
@@ -54,6 +58,7 @@ register-codec [
5458

5559
register-codec [
5660
name: 'bmp
61+
type: 'image
5762
title: "Portable Bitmap"
5863
suffixes: [%.bmp]
5964

@@ -64,6 +69,7 @@ register-codec [
6469

6570
register-codec [
6671
name: 'jpegxr
72+
type: 'image
6773
title: "JPEG extended range"
6874
suffixes: [%.jxr %.hdp %.wdp]
6975

@@ -74,6 +80,7 @@ register-codec [
7480

7581
register-codec [
7682
name: 'jpeg
83+
type: 'image
7784
title: "Joint Photographic Experts Group"
7885
suffixes: [%.jpg %.jpeg]
7986

@@ -84,26 +91,11 @@ register-codec [
8491

8592
register-codec [
8693
name: 'png
94+
type: 'image
8795
title: "Portable Network Graphics"
8896
suffixes: [%.png]
8997

9098
decode: func [data [binary!]][lib/image/load/as data 'PNG]
9199
encode: func [data [image! ]][lib/image/save/as none data 'PNG]
92100
identify: func [data [binary!]][parse data [#{89504E47} to end]]
93101
]
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-

src/mezz/codec-json.reb

+1
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ to-json: function [
451451

452452
register-codec [
453453
name: 'json
454+
type: 'text
454455
title: "JavaScript Object Notation"
455456
suffixes: [%.json]
456457

src/mezz/codec-pkix.reb

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ wrap [
1717

1818
register-codec [
1919
name: 'pkix
20+
type: 'cryptography
2021
title: "Public-Key Infrastructure (X.509)"
2122
suffixes: [%.pem %.ssh %.certSigningRequest]
2223
decode: function[

src/mezz/codec-ppk.reb

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ REBOL [
1111

1212
register-codec [
1313
name: 'ppk
14+
type: 'cryptography
1415
title: "PuTTY Private Key"
1516
suffixes: [%.ppk]
1617

src/mezz/codec-ssh-key.reb

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ wrap [
2929

3030
register-codec [
3131
name: 'ssh-key
32+
type: 'cryptography
3233
title: "Secure Shell Key"
3334
suffixes: [%.key]
3435

src/mezz/codec-swf.reb

+1
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,7 @@ import module [
12241224

12251225
register-codec [
12261226
name: 'swf
1227+
type: 'application
12271228
title: "ShockWave Flash"
12281229
suffixes: [%.swf]
12291230

src/mezz/codec-tar.reb

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ REBOL [
1818

1919
register-codec [
2020
name: 'tar
21+
type: 'compression
2122
title: "TAR File Format"
2223
suffixes: [%.tar]
2324

src/mezz/codec-unixtime.reb

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ REBOL [
1515

1616
register-codec [
1717
name: 'unixtime
18+
type: 'time
1819
title: "Unix time stamp converter"
1920
suffixes: []
2021

src/mezz/codec-utc-time.reb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ REBOL [
88

99
register-codec [
1010
name: 'utc-time
11+
type: 'time
1112
title: "UTC time as used in ASN.1 data structures (BER/DER)"
1213
decode: function [
1314
"Converts DER/BER UTC-time data to Rebol date! value"

src/mezz/codec-wav.reb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ REBOL [
1616

1717
register-codec [
1818
name: 'wav
19+
type: 'sound
1920
title: "Waveform Audio File Format"
2021
suffixes: [%.wav %.wave]
2122

src/mezz/codec-xml.reb

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ REBOL [
173173

174174
register-codec [
175175
name: 'xml
176+
type: 'text
176177
title: "Extensible Markup Language"
177178
suffixes: [%.xml %.pom]
178179

src/mezz/codec-zip.reb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ REBOL [
1616

1717
register-codec [
1818
name: 'zip
19+
type: 'compression
1920
title: "ZIP File Format"
2021
suffixes: [%.zip %.aar %.jar %.apk %.zipx %.appx %.epub]
2122

0 commit comments

Comments
 (0)