X Tutup
Skip to content

Commit aa8bc1d

Browse files
author
Johan Brichau
committed
Added the unmodified GRUtf8CodecStream to the Gemstone200 package
1 parent 8a01041 commit aa8bc1d

File tree

10 files changed

+82
-1
lines changed

10 files changed

+82
-1
lines changed

repository/Grease-GemStone200-Core.package/GRUtf8CodecStream.class/README.md

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
streaming
2+
crlf
3+
binary
4+
ifTrue: [
5+
stream nextPut: 13.
6+
stream nextPut: 10 ]
7+
ifFalse: [
8+
stream nextPut: Character cr.
9+
stream nextPut: Character lf ]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
private
2+
invalidUtf8
3+
^GRInvalidUtf8Error signal: 'Invalid UTF-8 input'
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
streaming
2+
next: anInteger
3+
"Convert the given string from UTF-8 using the fast path if converting to Latin-1"
4+
| outStream byte1 byte2 byte3 byte4 unicode count |
5+
outStream := WriteStream on: (String new: anInteger).
6+
count := 0.
7+
[ count < anInteger and: [ stream atEnd not ] ] whileTrue: [
8+
byte1 := stream next.
9+
unicode := byte1.
10+
(byte1 bitAnd: 16rE0) = 192 ifTrue: [ "two bytes"
11+
byte2 := stream next.
12+
(byte2 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
13+
unicode := ((byte1 bitAnd: 31) bitShift: 6) + (byte2 bitAnd: 63)].
14+
(byte1 bitAnd: 16rF0) = 224 ifTrue: [ "three bytes"
15+
byte2 := stream next.
16+
(byte2 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
17+
byte3 := stream next.
18+
(byte3 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
19+
unicode := ((byte1 bitAnd: 15) bitShift: 12) + ((byte2 bitAnd: 63) bitShift: 6)
20+
+ (byte3 bitAnd: 63)].
21+
(byte1 bitAnd: 16rF8) = 240 ifTrue: [ "four bytes"
22+
byte2 := stream next.
23+
(byte2 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
24+
byte3 := stream next.
25+
(byte3 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
26+
byte4 := stream next.
27+
(byte4 bitAnd: 16rC0) = 16r80 ifFalse: [ self invalidUtf8 ].
28+
unicode := ((byte1 bitAnd: 16r7) bitShift: 18) +
29+
((byte2 bitAnd: 63) bitShift: 12) +
30+
((byte3 bitAnd: 63) bitShift: 6) +
31+
(byte4 bitAnd: 63)].
32+
unicode ifNil: [ self invalidUtf8 ].
33+
unicode = 16rFEFF "ignore BOM" ifFalse: [
34+
outStream nextPut: (Character codePoint: unicode).
35+
count := count + 1 ].
36+
unicode := nil ].
37+
^outStream contents
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
streaming
2+
nextPut: aCharacter
3+
self nextPutAll: (String with: aCharacter)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
streaming
2+
nextPutAll: aString
3+
binary
4+
ifTrue: [ stream nextPutAll: aString asString ]
5+
ifFalse: [ stream nextPutAll: aString encodeAsUTF8 asString ]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"class" : {
3+
},
4+
"instance" : {
5+
"crlf" : "dkh 11/06/2009 08:45",
6+
"invalidUtf8" : "dkh 11/06/2009 08:45",
7+
"next:" : "DaleHenrichs 08/27/2010 10:45",
8+
"nextPut:" : "dkh 11/06/2009 08:45",
9+
"nextPutAll:" : "dkh 05/24/2012 09:50" } }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"category" : "Grease-GemStone200-Core",
3+
"classinstvars" : [
4+
],
5+
"classvars" : [
6+
],
7+
"commentStamp" : "",
8+
"instvars" : [
9+
],
10+
"name" : "GRUtf8CodecStream",
11+
"pools" : [
12+
],
13+
"super" : "GRTextOrBinaryCodecStream",
14+
"type" : "normal" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SystemOrganization addCategory: #'Grease-GemStone200-Core'!

repository/Grease-GemStone200-Core.package/monticello.meta/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(name 'Grease-GemStone200-Core-dkh.2' message '3.0.6.1 (dkh.338):- GemStone 3.0.1 fix for Issue 130: remote breakpoints don''''t work http://code.google.com/p/glassdb/issues/detail?id=130' id 'aecee0e8-add0-4657-b4c8-4eea538e526f' date '10/14/2011' time '17:50:58' author 'dkh' ancestors ((name 'Grease-GemStone200-Core-dkh.1' message '1.0.6.1 (dkh.159):- port to GemStone 3.0.1 (#generatehardBreak changed for 3.0)' id '864f5d8b-0f4b-44f0-ad7a-1dd0f961a6db' date '10/14/2011' time '17:03:59' author 'dkh' ancestors () stepChildren ())) stepChildren ())
1+
(name 'Grease-GemStone200-Core-JohanBrichau.3' message 'Fix for slow UTF8 encoding in GemStone3.x (see https://github.com/GsDevKit/Grease/issues/2 )' id 'fa78339a-9385-4a26-9b78-67f961b3e0ab' date '10/19/2014' time '15:57:54' author 'JohanBrichau' ancestors ((name 'Grease-GemStone200-Core-dkh.2' message '3.0.6.1 (dkh.338):- GemStone 3.0.1 fix for Issue 130: remote breakpoints don''''t work http://code.google.com/p/glassdb/issues/detail?id=130' id 'aecee0e8-add0-4657-b4c8-4eea538e526f' date '10/14/2011' time '17:50:58' author 'dkh' ancestors ((name 'Grease-GemStone200-Core-dkh.1' message '1.0.6.1 (dkh.159):- port to GemStone 3.0.1 (#generatehardBreak changed for 3.0)' id '864f5d8b-0f4b-44f0-ad7a-1dd0f961a6db' date '10/14/2011' time '17:03:59' author 'dkh' ancestors () stepChildren ())) stepChildren ())) stepChildren ())

0 commit comments

Comments
 (0)
X Tutup