Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-07

Re: WinCE port patches

21 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Florian Klaempfl

Yury Sidorov wrote:

Moved to fpc-devel because contains stuff which needs probably more discussion.

Show quoted text 24 lines
>>>> 2. WinCE is unicode only OS. How would be better to handle it? RTL >>>> has variables/function parameters wich are PChar/Strings. I think >>>> in unicode systems PWideChar/WideStrings should be used. >>> >>> >>> >>> Yes. Introduce some TOSString for the windows rtl which is >>> ansistring on non ce and widestring on ce and use it if ansistring >>> is suffient. >> >> >> >> And POSChar for PChar/PWideChar. Or maybe SysString and PSysChar? >> Modifications in many files will be needed. Who will do that? > > > I meant mainly for the system unit etc., not the windows unit, so it > shouldn't be that much. I meant types must be defined in system units for other targets too. For example there is global variable cmdline. Currently it is PChar and it is assigned in every system unit. We will change it to PSysChar and PSysChar must be defined properly in every system unit.

The question is if the real command line shouldn't be assigned to the PChar cmdline. If someone wants the unicode command line he should use a WinCE syscall. How is this handled in the GNU port to arm-wince? What type does argv have?

Show quoted text 8 lines
> About the windows unit: does M$ deliver the same header files for > wince and the rest? If not, I would propose to generate a new windows > for wince unit using h2pas. For the beginning the most important > functions should be enough. The headers are different. Were Win32 units created using h2pas?

Yes. The windows unit was done this way, however, the GNU headers instead of the MS ones were used.

I will try to generate WinCE units...

Reply by email

Yury Sidorov
to Florian Klaempfl

From: "Florian Klaempfl"

Show quoted text 28 lines
>>>>> 2. WinCE is unicode only OS. How would be better to handle it? RTL >>>>> has variables/function parameters wich are PChar/Strings. I think in >>>>> unicode systems PWideChar/WideStrings should be used. >>>> >>>> >>>> >>>> Yes. Introduce some TOSString for the windows rtl which is ansistring >>>> on non ce and widestring on ce and use it if ansistring is suffient. >>> >>> >>> >>> And POSChar for PChar/PWideChar. Or maybe SysString and PSysChar? >>> Modifications in many files will be needed. Who will do that? >> >> >> I meant mainly for the system unit etc., not the windows unit, so it >> shouldn't be that much. > > > I meant types must be defined in system units for other targets too. For > example there is global variable cmdline. Currently it is PChar and it is > assigned in every system unit. We will change it to PSysChar and PSysChar > must be defined properly in every system unit. The question is if the real command line shouldn't be assigned to the PChar cmdline. If someone wants the unicode command line he should use a WinCE syscall. How is this handled in the GNU port to arm-wince? What type does argv have?

In GCC for WinCE argv[] is char* and conversions from Unicode to ANSI are performed.
The same conversions can be done in FPC too.

So what way should we go?

1. Leave RTL string types as is (PChar/AnsiString) and perform conversion from Unicode if needed.

2. Define new types PSysChar/SysString to correspond either PChar/AnsiString or PWideChar/WideString depending from OS type.

3. Be avare of UNICODE define and produce fully Unicode RTL if it is defined and ANSI RTL if it is not defined.

Yury Sidorov.

Reply by email

Yury Sidorov
to Florian Klaempfl: Moved to fpc-devel because contains stuff which needs probably more discussion. The…

From: "Florian Klaempfl"

Show quoted text 9 lines
>> About the windows unit: does M$ deliver the same header files for >> wince and the rest? If not, I would propose to generate a new windows >> for wince unit using h2pas. For the beginning the most important >> functions should be enough. > > The headers are different. Were Win32 units created using h2pas? Yes. The windows unit was done this way, however, the GNU headers instead of the MS ones were used.

Can MS WinCE headers be used for conversion? Or is there copyright problem?

Yury Sidorov.

Reply by email

Hans-Peter Diettrich
to Yury Sidorov: From: "Florian Klaempfl" In GCC for WinCE argv[] is char* and conversions from Unicode to…
Yury Sidorov wrote
So what way should we go? 1. Leave RTL string types as is (PChar/AnsiString) and perform conversion from Unicode if needed.

No problem.

2. Define new types PSysChar/SysString to correspond either PChar/AnsiString or PWideChar/WideString depending from OS type.

It's not a good idea to have String as WideString *without* reference counting on WinCE, and Wide or Ansi strings *with* reference counting in other cases.

3. Be avare of UNICODE define and produce fully Unicode RTL if it is defined and ANSI RTL if it is not defined.

As above, exchangable Char and String types only should differ in the character size, not in the automatic handling of string memory (refcount, copy-on-write...).

Does anybody know good reasons for making strings *not* reference counted?
Is this behaviour related to inter-task communication? What about transferring strings from one process to another one, on various platforms?

How do MS compilers handle code written for both Ansi and Unicode environments, and the related data types? How are string arguments (out) handled in Windows API's?
Is this Microsoft way a good model for other platforms?

DoDi

Reply by email

Yury Sidorov
to Hans-Peter Diettrich

From: "Hans-Peter Diettrich"

Show quoted text 7 lines
> 2. Define new types PSysChar/SysString to correspond either > PChar/AnsiString > or PWideChar/WideString depending from OS type. It's not a good idea to have String as WideString *without* reference counting on WinCE, and Wide or Ansi strings *with* reference counting in other cases.

I did not say anything about ref-counting in strings. WideStrings are refcounted as well as AnsiStrings.

I meant the following:

In WinCE system unit define:

type
  PSysChar = PWideChar;
  SysString = WideString;

Then modify some OS related RTL variables/functions to use theese PSysChar/SysString types.
For example:

var
  cmdline: PSysChar;
...
function paramstr(l : longint) : SysString;
...

System units for non-unicode OSes will define theese types as:

type
  PSysChar = PChar;
  SysString = AnsiString;

Yury Sidorov.

Reply by email

Yury Sidorov
to Hans-Peter Diettrich: No problem. It's not a good idea to have String as WideString *without* reference…

From: "Hans-Peter Diettrich"

How do MS compilers handle code written for both Ansi and Unicode environments, and the related data types? How are string arguments (out) handled in Windows API's? Is this Microsoft way a good model for other platforms?

MS provides types for strngs/characters which are become differ if UNICODE is defined or not.
For example LPCTSTR is an LPCWSTR if UNICODE is defined, an LPCTSTR otherwise.
Therefore UNICODE define can easily convert MS RTL to unicode and non-unicode versions.

Yury Sidorov.

Reply by email

Alexey Barkovoy
to Yury Sidorov
Show quoted text 11 lines
> How do MS compilers handle code written for both Ansi and Unicode > environments, and the related data types? How are string arguments (out) > handled in Windows API's? > Is this Microsoft way a good model for other platforms? MS provides types for strngs/characters which are become differ if UNICODE is defined or not. For example LPCTSTR is an LPCWSTR if UNICODE is defined, an LPCTSTR otherwise. Therefore UNICODE define can easily convert MS RTL to unicode and non-unicode versions.

And for Borland plan always was:

{$IFDEF UNICODE}
  String = WideString;
  Char = WideChar;
{$ELSE}
  String = AnsiString;
  Char = AnsiChar;
{$END}

but seems it will not be realized for some or other reasons.

Reply by email

Yury Sidorov
to Alexey Barkovoy

From: "Alexey Barkovoy"

Show quoted text 15 lines
> MS provides types for strngs/characters which are become differ if > UNICODE is defined or not. > For example LPCTSTR is an LPCWSTR if UNICODE is defined, an LPCTSTR > otherwise. > Therefore UNICODE define can easily convert MS RTL to unicode and > non-unicode versions. And for Borland plan always was: {$IFDEF UNICODE} String = WideString; Char = WideChar; {$ELSE} String = AnsiString; Char = AnsiChar; {$END}

I think String and Char types must be leaved as is, but new types like SysChar/SysString can be defined for unicode support.

Yury Sidorov.

Reply by email

Florian Klaempfl
to Yury Sidorov: From: "Hans-Peter Diettrich" I did not say anything about ref-counting in strings.…
Yury Sidorov wrote 31 lines
From: "Hans-Peter Diettrich" >> 2. Define new types PSysChar/SysString to correspond either >> PChar/AnsiString >> or PWideChar/WideString depending from OS type. > > > It's not a good idea to have String as WideString *without* reference > counting on WinCE, and Wide or Ansi strings *with* reference counting in > other cases. I did not say anything about ref-counting in strings. WideStrings are refcounted as well as AnsiStrings. I meant the following: In WinCE system unit define: type PSysChar = PWideChar; SysString = WideString; Then modify some OS related RTL variables/functions to use theese PSysChar/SysString types. For example: var cmdline: PSysChar; ... function paramstr(l : longint) : SysString;

I would leave it an ansistring. Experience showed that people expect that functions behave on all OSes the same way. Add an additional paramstrw.

Show quoted text 15 lines
... System units for non-unicode OSes will define theese types as: type PSysChar = PChar; SysString = AnsiString; Yury Sidorov. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Yury Sidorov
to Florian Klaempfl

From: "Florian Klaempfl"

Show quoted text 32 lines
>>> 2. Define new types PSysChar/SysString to correspond either >>> PChar/AnsiString >>> or PWideChar/WideString depending from OS type. >> >> >> It's not a good idea to have String as WideString *without* reference >> counting on WinCE, and Wide or Ansi strings *with* reference counting in >> other cases. > > > I did not say anything about ref-counting in strings. WideStrings are > refcounted as well as AnsiStrings. > > I meant the following: > > In WinCE system unit define: > > type > PSysChar = PWideChar; > SysString = WideString; > > Then modify some OS related RTL variables/functions to use theese > PSysChar/SysString types. > For example: > > var > cmdline: PSysChar; > ... > function paramstr(l : longint) : SysString; I would leave it an ansistring. Experience showed that people expect that functions behave on all OSes the same way. Add an additional paramstrw.

Ok. All unicode strings will be converted to ansistrings in WinCE RTL.

Yury Sidorov.

Reply by email

Yury Sidorov

Hello,

I found that try...except and try...finally do not work if SysUtils unit is not used (exception handling code is not called).
The attached patch fixes this issue.

Yury Sidorov,

Reply by email

Yury Sidorov

Hello,

I found that try...except and try...finally do not work if SysUtils unit is not used (exception handling code is not called).
The following patch fixes this issue.

Index: system.inc
===================================================================
--- system.inc (revision 594)
+++ system.inc (working copy)
@@ -674,7 +674,10 @@
 Procedure HandleErrorAddrFrame (Errno : longint;addr,frame :
Pointer);[public,alias:'FPC_BREAK_ERROR'];
 begin
   If pointer(ErrorProc)Nil then
-    ErrorProc(Errno,addr,frame);
+    ErrorProc(Errno,addr,frame)
+  else
+    if frame  nil then
+      raise TObject(nil) at addr,frame;
   errorcode:=word(Errno);
   erroraddr:=addr;
   errorbase:=frame;

By the way, messages with attachment are not posted to mailing list. Is it ok?

Yury Sidorov,

Reply by email

Florian Klaempfl
to Yury Sidorov: I found that try...except and try...finally do not work if SysUtils unit is not used…
Yury Sidorov wrote 5 lines
Hello, I found that try...except and try...finally do not work if SysUtils unit is not used (exception handling code is not called). The following patch fixes this issue.

Not using sysutils means that you don't want exceptions. If you want to have run time errors converted into exceptions use sysutils. The patch has another probably undesired side effect: imaging someone installed an own errorproc to release resources (memory etc.) if he did so, he won't get that exception.

Show quoted text 31 lines
Index: system.inc =================================================================== --- system.inc (revision 594) +++ system.inc (working copy) @@ -674,7 +674,10 @@ Procedure HandleErrorAddrFrame (Errno : longint;addr,frame : Pointer);[public,alias:'FPC_BREAK_ERROR']; begin If pointer(ErrorProc)Nil then - ErrorProc(Errno,addr,frame); + ErrorProc(Errno,addr,frame) + else + if frame nil then + raise TObject(nil) at addr,frame; errorcode:=word(Errno); erroraddr:=addr; errorbase:=frame; By the way, messages with attachment are not posted to mailing list. Is it ok? Yury Sidorov, _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Yury Sidorov
to Florian Klaempfl: Not using sysutils means that you don't want exceptions. If you want to have run time…

From: "Florian Klaempfl"

Show quoted text 11 lines
> I found that try...except and try...finally do not work if SysUtils unit > is > not used (exception handling code is not called). > The following patch fixes this issue. Not using sysutils means that you don't want exceptions. If you want to have run time errors converted into exceptions use sysutils. The patch has another probably undesired side effect: imaging someone installed an own errorproc to release resources (memory etc.) if he did so, he won't get that exception.

I think try/finally/except should work without SysUtils. It works in Delphi. For example KOL library does not use SysUtils, but programmer can use try/finally/except to write crash-proof code.

In my final patch the described side effect with ErrorProc is solved. The exception will be raised after ErrorProc exit. Also stack dump on unhandled exception is fixed.

So I can not see any reason to do not include this patch...

Yury Sidorov,

Reply by email

Florian Klaempfl
to Yury Sidorov
Yury Sidorov wrote 24 lines
From: "Florian Klaempfl" >> I found that try...except and try...finally do not work if SysUtils >> unit is >> not used (exception handling code is not called). >> The following patch fixes this issue. > > > Not using sysutils means that you don't want exceptions. If you want > to have run > time errors converted into exceptions use sysutils. The patch has another > probably undesired side effect: imaging someone installed an own > errorproc to > release resources (memory etc.) if he did so, he won't get that > exception. I think try/finally/except should work without SysUtils. It works in Delphi. For example KOL library does not use SysUtils, but programmer can use try/finally/except to write crash-proof code. In my final patch the described side effect with ErrorProc is solved. The exception will be raised after ErrorProc exit. Also stack dump on unhandled exception is fixed.

Looks good.

So I can not see any reason to do not include this patch...

Applied, thx.

Reply by email

L505
to Yury Sidorov: I had problems with my mailbox. Please resent your answer to this topic to my mailbox…

I think the idea is that exception handling should be kept separate in case a user wants to use his own exception handling. If the user explicitly wants to use exception handling, he just includes the sysutils unit.

However, I suppose if the sysutils unit involves some extra code bloat (due to initialization and finalization), and the user doesn't want to use sysutils in his project at all (but he does want exception handling) then there should be an option to use exception handling without the sysutils unit? (maybe a {$MODE HandleException} ?)

Earlier message 26 lines
----- Original Message ----- From: "Yury Sidorov" To: "FPC developers' list" Sent: Thursday, July 07, 2005 10:48 AM Subject: [fpc-devel] Re: Patch: Exception handling without SysUtils | Hello, | | I had problems with my mailbox. Please resent your answer to this topic to | my mailbox | | Also, the previos patch was not complete. Here is complete and tested | version. | | Yury Sidorov, | -------------------------------------------------------------------------------- | _______________________________________________ | fpc-devel maillist - | http://lists.freepascal.org/mailman/listinfo/fpc-devel |

Reply by email

Florian Klaempfl
to Tomas Hajny: Date sent: Thu, 07 Jul 2005 20:53:48 +0200 From: Florian Klaempfl To: …
Tomas Hajny wrote 32 lines
Date sent: Thu, 07 Jul 2005 20:53:48 +0200 From: Florian Klaempfl To: FPC developers' list Subject: Re: [fpc-devel] Patch: Exception handling without SysUtils Send reply to: FPC developers' list >Yury Sidorov wrote: > > >>From: "Florian Klaempfl" >> >>>>I found that try...except and try...finally do not work if >>>>SysUtils unit is not used (exception handling code is not called). >>>>The following patch fixes this issue. >>> >>> >>>Not using sysutils means that you don't want exceptions. If you >>>want to have run time errors converted into exceptions use >>>sysutils. The patch has another probably undesired side effect: >>>imaging someone installed an own errorproc to release resources >>>(memory etc.) if he did so, he won't get that exception. >> >> >>I think try/finally/except should work without SysUtils. It works in >>Delphi. For example KOL library does not use SysUtils, but >>programmer can use try/finally/except to write crash-proof code. Isn't SysUtils used automatically in Delphi mode? That should be probably enough for Delphi compatibility, shouldn't it?

No.

Reply by email

Tomas Hajny
to Florian Klaempfl: Looks good. Applied, thx.

Date sent: Thu, 07 Jul 2005 20:53:48 +0200
From: Florian Klaempfl
To: FPC developers' list
Subject: Re: [fpc-devel] Patch: Exception handling without SysUtils Send reply to: FPC developers' list

Show quoted text 19 lines
Yury Sidorov wrote: > From: "Florian Klaempfl" > >>> I found that try...except and try...finally do not work if >>> SysUtils unit is not used (exception handling code is not called). >>> The following patch fixes this issue. >> >> >> Not using sysutils means that you don't want exceptions. If you >> want to have run time errors converted into exceptions use >> sysutils. The patch has another probably undesired side effect: >> imaging someone installed an own errorproc to release resources >> (memory etc.) if he did so, he won't get that exception. > > > I think try/finally/except should work without SysUtils. It works in > Delphi. For example KOL library does not use SysUtils, but > programmer can use try/finally/except to write crash-proof code.

Isn't SysUtils used automatically in Delphi mode? That should be probably enough for Delphi compatibility, shouldn't it?

Tomas

Reply by email