[fpc-devel] procedure Types
I have problem with procedure Types. Look at the following code: TProcedure= procedure (S: String); TTest= class MyF: TProcedure; procedure F1 (S: String); procedure F2 (S: String); ... end; TTest.constructor ; begin MyF:= @F1; end; it says it can't cast Procedure (S: String); Object to TProcedure. The problem is clear but I don't know (can't find) any solution to define TProcedure as a procedure of a class which accepts one argument. Yours Amir ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] procedure Types
On Saturday 04 March 2006 10:09, Amir Aavani wrote: I have problem with procedure Types. Look at the following code: TProcedure= procedure (S: String); TTest= class MyF: TProcedure; procedure F1 (S: String); procedure F2 (S: String); ... end; TTest.constructor ; begin MyF:= @F1; end; it says it can't cast Procedure (S: String); Object to TProcedure. The problem is clear but I don't know (can't find) any solution to define TProcedure as a procedure of a class which accepts one argument. You have declared MyF as a TProcedure, so this is just not going to work. Try this instead: type TMyFProc = Procedure(S: String) of Object; ... MyF: TMyFProc; ... that should work. -- Regards, Christian Iversen ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] procedure Types
On Sat, 4 Mar 2006, Amir Aavani wrote: I have problem with procedure Types. Look at the following code: TProcedure= procedure (S: String); TTest= class MyF: TProcedure; procedure F1 (S: String); procedure F2 (S: String); ... end; TTest.constructor ; begin MyF:= @F1; end; it says it can't cast Procedure (S: String); Object to TProcedure. The problem is clear but I don't know (can't find) any solution to define TProcedure as a procedure of a class which accepts one argument. Try the following (note the 'of object' in the declaration): Type TMyStringProc = procedure (S : String) of object; and then MyF : TMyStringProc; This is documented. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] libp***.a
what are the libp***.a files for? ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] libp***.a
On Thu, 2 Mar 2006, Rod wrote: what are the libp***.a files for? These are units compiled with smartlinking. If you use the smartlinking feature, then the .a files are used instead of the .o files. Takes longer to link, but the resulting binaries are smaller. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] libp***.a
what are the libp***.a files for? Now: smartlinking. In the future: gone, or changed to they original meaning, static lib (like .lib with VC). (An .a is an archive of .o's) See also buildfaq (I hope it is more verbosely in there somewhere): http://www.stack.nl/~marcov/buildfaq.pdf ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] procedure Types
Thanks to Michael and Christian. It works correctly. I think it could be usefull to put an example for this case in fpc docs. Michael Van Canneyt wrote: On Sat, 4 Mar 2006, Amir Aavani wrote: I have problem with procedure Types. Look at the following code: TProcedure= procedure (S: String); TTest= class MyF: TProcedure; procedure F1 (S: String); procedure F2 (S: String); ... end; TTest.constructor ; begin MyF:= @F1; end; it says it can't cast Procedure (S: String); Object to TProcedure. The problem is clear but I don't know (can't find) any solution to define TProcedure as a procedure of a class which accepts one argument. Try the following (note the 'of object' in the declaration): Type TMyStringProc = procedure (S : String) of object; and then MyF : TMyStringProc; This is documented. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Type definition
If there compelling reason why type definitions cannot be included in class/object definitions? Make it mode FPC to keep folks happy :) Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. P Davidson Corax Networks Inc. http://CoraxNetworks.com IMPORTANT NOTICE: This message is intended only for the use of the individual or entity to which it is addressed. The message may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Corax Networks immediately by email at [EMAIL PROTECTED] Thank you. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Type definition
Paul Davidson wrote: If there compelling reason why type definitions cannot be included in class/object definitions? Make it mode FPC to keep folks happy :) Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. P Davidson Corax Networks Inc. http://CoraxNetworks.com IMPORTANT NOTICE: This message is intended only for the use of the individual or entity to which it is addressed. The message may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Corax Networks immediately by email at [EMAIL PROTECTED] Thank you. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel I second this request. Throw in const fields too.. Ales ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Type definition
On Sat, 4 Mar 2006 10:24:14 -0500 Paul Davidson [EMAIL PROTECTED] wrote: Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. Can you elaborate on the second point ? Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Type definition
unit aUnit; interface type aType = ( at_First, at_aaa, at_bbb, at_Last ); aObj = class aVar : aType unit bUnit; interface uses aUnit; type bObj = class( aObj ) unit cUnit interface uses bUnit; type cObj = class( bObj ) implementation aVar := at_Last; --- ERROR! The implementation of cUnit requires a USE aUnit; in order to compile since at_last is no longer visible. On Mar 4, 2006, at 12:49, Micha Nelissen wrote: On Sat, 4 Mar 2006 10:24:14 -0500 Paul Davidson [EMAIL PROTECTED] wrote: Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. Can you elaborate on the second point ? Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel P Davidson Corax Networks Inc. http://CoraxNetworks.com IMPORTANT NOTICE: This message is intended only for the use of the individual or entity to which it is addressed. The message may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify Corax Networks immediately by email at [EMAIL PROTECTED] Thank you. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] fcl/image/fpwritexpm fix
The attached patch fixes two crashes I had with TFPWriterXPM: 1. If there was more than 60 or so colours in the palette 2. If the TFPCustomImage did not have a palette. Colin diff -uNr trunk/fpcsrc/fcl/image/fpwritexpm.pp trunk.w/fpcsrc/fcl/image/fpwritexpm.pp --- trunk/fpcsrc/fcl/image/fpwritexpm.pp 2005-06-11 09:58:32.0 +0100 +++ trunk.w/fpcsrc/fcl/image/fpwritexpm.pp 2006-02-25 14:12:23.0 + @@ -76,6 +76,7 @@ procedure TFPWriterXPM.InternalWrite (Str:TStream; Img:TFPCustomImage); var p, l : TStringList; c, len, r, t : integer; +TmpPalette, Palette: TFPPalette; procedure BuildPaletteStrings; var r,c,e : integer; procedure MakeCodes (const head:string; charplace:integer); @@ -85,12 +86,13 @@ dec (charplace); while (r = e) and (c = 0) do begin -if Charplace = 1 then +if Charplace 0 then MakeCodes (head+PalChars[r],charplace) -else +else begin p.Add (head+PalChars[r]); + dec(c); +end; inc (r); -dec(c); end; end; begin @@ -98,7 +100,7 @@ len := 1; e := length(PalChars); r := e; -c := img.palette.count; +c := Palette.count; while (r = c) do begin inc (len); @@ -123,25 +125,35 @@ begin l := TStringList.Create; p := TStringList.Create; + TmpPalette := nil; try l.Add ('/* XPM */'); l.Add ('static char *graphic[] = {'); -c := img.palette.count; +Palette := img.palette; +if not Assigned(Palette) then begin + TmpPalette := TFPPalette.Create(0); + TmpPalette.Build(Img); + Palette := TmpPalette; +end; +c := Palette.count; BuildPaletteStrings; l.add (format('%d %d %d %d,',[img.width,img.height,c,len])); InitConsts; for r := 0 to c-1 do begin - if img.palette[r] colTransparent then -l.Add (format('%s c #%s,',[p[r],ColorToHex(img.palette.color[r])])) + if Palette[r] colTransparent then +l.Add (format('%s c #%s,',[p[r],ColorToHex(Palette.color[r])])) else l.Add (format('%s c None,',[p[r]])); end; for r := 0 to img.Height-1 do begin - s := p[img.pixels[0,r]]; - for t := 1 to img.Width-1 do -s := s + p[img.pixels[t,r]]; + s := ''; + for t := 0 to img.Width-1 do +if Assigned(TmpPalette) then + s := s + p[TmpPalette.IndexOf(img.Colors[t,r])] +else + s := s + p[img.pixels[t,r]]; s := ''+s+''; if r img.Height-1 then s := s + ','; @@ -149,6 +161,7 @@ end; l.Add ('};'); finally +TmpPalette.Free; l.SaveToStream (Str); p.Free; l.Free; ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Type definition
If there compelling reason why type definitions cannot be included in class/object definitions? Make it mode FPC to keep folks happy :) Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. It breaks code and is therefor incompatible. A type symbol is never searched in an object, class or record symtable. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Type definition
On Sat, 4 Mar 2006, Peter Vreman wrote: If there compelling reason why type definitions cannot be included in class/object definitions? Make it mode FPC to keep folks happy :) Quite often a type is defined in INTERFACE part, but only used within class/object defined in same unit. 1) This means that type is public. This is not always good thing in OOese. 2) Unit must be specified in child's child's USE list. It breaks code and is therefor incompatible. A type symbol is never searched in an object, class or record symtable. At the most we could introduce a 'Private' type section in the unit interface section. But even that is not needed, as you can perfectly solve the problems without it, just use a class factory and inheritance. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] FExpand function
Hello, Should this comparison (!) be fixed? Seeing that this code is going to be changed, what about change Pa[I] assignment from a variable to a constant? rtl/inc/fexpand.inc (* Allow both '/' and '\' as directory separators *) (* by converting all to the native one. *) if DirectorySeparator = '\' then {Allow slash as backslash} begin for I := 1 to Length (Pa) do if Pa [I] = '/' then Pa [I] := DirectorySeparator end else ! if DirectorySeparator = '\' then {Allow backslash as slash} begin for I := 1 to Length (Pa) do if Pa [I] = '\' then Pa [I] := DirectorySeparator; end; Thanks, -- Joao Morais ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] FExpand function
On Sat, 4 Mar 2006, Joao Morais wrote: Hello, Should this comparison (!) be fixed? Seeing that this code is going to be changed, what about change Pa[I] assignment from a variable to a constant? The comparison can be fixed. In fact I think the code can be reduced to a single loop: if (DirectorySeparator='\') or (DirectorySeparator='/') then for I:=1 to Length(PA) do if (Pa[I] in ['\','/']) and (PA[I]DirectorySeparator) then Pa[I]:=DirectorySeparator; Could you test this, please ? Michael. rtl/inc/fexpand.inc (* Allow both '/' and '\' as directory separators *) (* by converting all to the native one. *) if DirectorySeparator = '\' then {Allow slash as backslash} begin for I := 1 to Length (Pa) do if Pa [I] = '/' then Pa [I] := DirectorySeparator end else ! if DirectorySeparator = '\' then {Allow backslash as slash} begin for I := 1 to Length (Pa) do if Pa [I] = '\' then Pa [I] := DirectorySeparator; end; Thanks, -- Joao Morais ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Type definition
On Sat, 4 Mar 2006 12:57:41 -0500 Paul Davidson [EMAIL PROTECTED] wrote: unit cUnit interface uses bUnit; type cObj = class( bObj ) implementation aVar := at_Last; --- ERROR! The implementation of cUnit requires a USE aUnit; in order to compile since at_last is no longer visible. This wouldn't be solved by nested types AFAICS ? Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel