issue-#19 Externalize & Internalize

User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#19 Externalize & Internalize

Post by Josef Templ »

luowy wrote: and the TextModels.Attributes.Internalize/Externalize need Utf-8 conversions in ReadXString/WriteXString for the font.typeface also.
luowy
I am afraid that there are even more ReadXString/WriteXString usages that need changes.
In order to make the changes simple and keep the code readable we should think
about extending Stores.Store with ReadUtf8String/WriteUtf8String methods.

- Josef
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#19 Externalize & Internalize

Post by Zinn »

Why don't you insert the Utf8 conversion into the procedure ReadReadXString/WriteXString directly? Then you don't have to search for all other changes.
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#19 Externalize & Internalize

Post by luowy »

Zinn wrote:Why don't you insert the Utf8 conversion into the procedure ReadReadXString/WriteXString directly? Then you don't have to search for all other changes.
great! maybe a final solution for such issues.
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#19 Externalize & Internalize

Post by Zinn »

Ivan Denisov wrote:Dear, Helmut, can you please create the voting for including this bug fix in master.
I will wait until I know what we do with the Luowy's problem. Do we stay on Josef's current solution or do we some further changes? Should we solve Luowy's problem here before we vote?
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#19 Externalize & Internalize

Post by luowy »

Search for the ReadXString, get these modules list( at least)

Code: Select all

Location	Count
Std\Mod\Headers.odc	5
System\Mod\Controls.odc	5
System\Mod\Stores.odc	5
Cpc\Mod\ETHConv.odc	3
Std\Mod\ETHConv.odc	3
Std\Mod\Links.odc	2
Cpc\Mod\ETHConvV4Elems.odc	1
Ole\Mod\Client.odc	1
Std\Mod\Folds.odc	1
Std\Mod\Stamps.odc	1
System\Mod\Views.odc	1
Text\Mod\Models.odc	1
for ReadXString use the ReadXChar, modify the ReadXChar/WriteXChar should get same result.

Code: Select all

(*
	PROCEDURE (VAR rd: Reader) ReadXChar* (OUT x: CHAR), NEW;
		VAR c: SHORTCHAR;
	BEGIN
		rd.rider.ReadByte(SYSTEM.VAL(BYTE,c)); x := c
	END ReadXChar;
*)
	
	PROCEDURE (VAR rd: Reader) ReadXChar* (OUT x: CHAR), NEW;
		VAR c: SHORTCHAR;
		VAR v: INTEGER;
	BEGIN
		rd.rider.ReadByte(SYSTEM.VAL(BYTE, c)); 
		IF c < 80X THEN                                              
			v := ORD(c);
		ELSIF c < 0E0X THEN                                       
			v := ORD(c) MOD 32;
			rd.rider.ReadByte(SYSTEM.VAL(BYTE, c)); 
			v := v * 64 + ORD(c) MOD 64
		ELSE                                                                  
			v := ORD(c) MOD 16;
			rd.rider.ReadByte(SYSTEM.VAL(BYTE, c)); 
			v := v * 64 + ORD(c) MOD 64;
			rd.rider.ReadByte(SYSTEM.VAL(BYTE, c)); 
			v := v * 64 + ORD(c) MOD 64;
		END;
		x:=CHR(v);
	END ReadXChar;
(*
	PROCEDURE (VAR wr: Writer) WriteXChar* (x: CHAR), NEW;
		VAR c: SHORTCHAR;
	BEGIN
		c := SHORT(x); wr.rider.WriteByte(SYSTEM.VAL(BYTE, c))
	END WriteXChar;
*)

	PROCEDURE (VAR wr: Writer) WriteXChar* (x: CHAR), NEW;
		VAR c: SHORTCHAR;
	BEGIN
		IF x < 80X THEN                                                   
			c:=SHORT(x);wr.rider.WriteByte(SYSTEM.VAL(BYTE, c))
		ELSIF x < 800X THEN                                         
			c:=SHORT(CHR(0C0H + ORD(x) DIV 64 )); wr.rider.WriteByte(SYSTEM.VAL(BYTE, c));
			c := SHORT(CHR( 80H + ORD(x) MOD 64 )); wr.rider.WriteByte(SYSTEM.VAL(BYTE, c));
		ELSE                                                                       
			c := SHORT(CHR(0E0H + ORD(x) DIV 4096)); wr.rider.WriteByte(SYSTEM.VAL(BYTE, c));
			c := SHORT(CHR(80H + ORD(x) DIV 64 MOD 64 )); wr.rider.WriteByte(SYSTEM.VAL(BYTE, c));
			c := SHORT(CHR(80H +  ORD(x) MOD 64 ));  wr.rider.WriteByte(SYSTEM.VAL(BYTE, c));
		END
	END WriteXChar;
though this fixup can solve my problem, but the side effect is obvious.
I can't find a perfect solution.

luowy
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#19 Externalize & Internalize

Post by Zinn »

luowy wrote: Search for the ReadXString, get these modules list( at least)
...
for ReadXString use the ReadXChar, modify the ReadXChar/WriteXChar should get same result.
though this fixup can solve my problem, but the side effect is obvious.
I can't find a perfect solution.
luowy
We can't change Read/WriteXChar, because it is used by StdETHConv. This module needs an unchanged Read/WriteXChar otherwise StdETHConv doesn't work.

We can change Read/WriteXString in the following way:

Code: Select all

	PROCEDURE (VAR rd: Reader) ReadXString* (OUT x: ARRAY OF CHAR), NEW;
		VAR res: INTEGER; utf8: Kernel.Utf8Name;
	BEGIN
		rd.ReadSString(utf8); Strings.Utf8ToString(utf8, x, res);  ASSERT(res = 0)
	END ReadXString;
...
	PROCEDURE (VAR wr: Writer) WriteXString* (IN x: ARRAY OF CHAR), NEW;
		VAR res: INTEGER; utf8: Kernel.Utf8Name;
	BEGIN
		Strings.StringToUtf8(x, utf8, res); ASSERT(res = 0); wr.WriteSString(utf8)
	END WriteXString;
I don't know how dangerous is this way. Another approach is to leave Read/WriteXString as it is and introduce new procedures Read/WriteUtf8. This way will be more secure, but we have to work through your list and change several Import/Export procedures.

Currently I have my test system running with the change of Read/WriteXString as described above. I didn't find any side effects.
- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#19 Externalize & Internalize

Post by Josef Templ »

It would be a horrible mistake to change ReadXString/WriteXString.
This would be an incompatible change. Not possible.

- Josef
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#19 Externalize & Internalize

Post by Zinn »

Josef,
do you insert
PROCEDURE (VAR rd: Reader) ReadUtf8* (OUT x: ARRAY OF CHAR), NEW;
and
PROCEDURE (VAR wr: Writer) WriteUtf8* (IN x: ARRAY OF CHAR), NEW;
into module Stores?

Or is this topic ready to vote?

- Helmut
Zinn
Posts: 476
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main
Contact:

Re: issue-#19 Externalize & Internalize

Post by Zinn »

Ivan,
please can you check that forms, guards and notifiers work with Cyrillic identifiers?
Thank you very much
- Helmut
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#19 Externalize & Internalize

Post by Josef Templ »

I didn't have time so far to look into this issue in more detail.
I hope I can do it today.

issue-#65 would be ready for voting, I think.

- Josef
Post Reply