Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Graeme Geldenhuys
On Wed, Jul 9, 2008 at 8:17 PM, Giulio Bernardi <[EMAIL PROTECTED]> wrote:
>> So I assume we have a cross-platform resource compiler now, so is
>> windres unnecessary? Was pre-processing also implemented?
>
> No. To compile .rc files to .res you still need windres. In general you can
> compile and run it fine on little endian machines, but it doesn't work (at
> least, it didn't work 6 months ago, don't know if newer versions are endian
> safe) on big endian machines.

So is that the technical issue with cross-platform resource compilers?
The endian handling? Or is there some other technical issue? I
remember even Kylix didn't have a resource compiler and couldn't
understand why.  After all, most C/C++ compilers are cross platform
and they seem to have resource compilers, so what is wrong with Object
Pascal compilers...

Sorry if this is dumb, but I obviously don't understand the full issue here...


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] csLoading

2008-07-09 Thread Vincent Snijders

Martin Schreiber schreef:

On Wednesday 09 July 2008 23.24:31 Vincent Snijders wrote:

Hi,

This is sequel to this thread of almost two years ago:
http://lists.freepascal.org/lists/fpc-devel/2006-September/008737.html

Some things changed (e.g. TComponent.Loading has been added), but I stil
did not find an easy way to fix lazarus bug 7305.

Looking at TReader.ReadComponent I have two questions:
First, why is for inline components csLoading set before the constructor
is called and why for other components after the constructor is called.
Having csLoading set before the constructor would help me to decide to
set the default values for the collection or not.


You could check csLoading of the AOwner parameter.



Thanks. That is a good suggestion. I'll use it if nothing better comes up.

Vincent
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] csLoading

2008-07-09 Thread Martin Schreiber
On Wednesday 09 July 2008 23.24:31 Vincent Snijders wrote:
> Hi,
>
> This is sequel to this thread of almost two years ago:
> http://lists.freepascal.org/lists/fpc-devel/2006-September/008737.html
>
> Some things changed (e.g. TComponent.Loading has been added), but I stil
> did not find an easy way to fix lazarus bug 7305.
>
> Looking at TReader.ReadComponent I have two questions:
> First, why is for inline components csLoading set before the constructor
> is called and why for other components after the constructor is called.
> Having csLoading set before the constructor would help me to decide to
> set the default values for the collection or not.
>
You could check csLoading of the AOwner parameter.

Martin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Paul Ishenin

Michael Van Canneyt wrote:

On Wed, 9 Jul 2008, Craig Peterson wrote:

  

Does any version of FPC support the {$R file} syntax for resources on
non-Windows targets?  I'd prefer that to Lazarus's LResources unit.  I have
the impression that some work on it was done as part of Simon Kissel's
CrossFPC project, but I haven't been able to verify that.  Was work done and
never completed?  Is it a TODO that just doesn't have anyone to work on it?



All targets in 2.3.1 now support {$R file} syntax
And lazarus with fpc 2.3.1 can load forms from native resources. If you 
look at LResources.pas you will see:

{$IFDEF FPC_HAS_WINLIKERESOURCES}
 {$DEFINE UseRES}
{$ENDIF}

There you can also look how UseRES is used.

Best regards,
Paul Ishenin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] csLoading

2008-07-09 Thread Graeme Geldenhuys
2008/7/9 Vincent Snijders <[EMAIL PROTECTED]>:
> Secondly, why isn't TComponent.Loading called to set the csLoading flag?

That would make sense and be more consistent.  I think it might have
been a oversight when TComponent.Loading was implemented.

>  IIRC Graeme just needed it protected so he could call it.

Yup, that was my only request at the time. Without Loading() I
couldn't set the ComponentState field and reuse the existing csLoading
flag. I don't use the stream classes (TReader/TWriter) to construct
and setup my components in fpGUI, I use plain Object Pascal and their
properties. In my case csLoading is used to control whether events
fire or not, when properties are modified.


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] csLoading

2008-07-09 Thread Vincent Snijders

Hi,

This is sequel to this thread of almost two years ago: 
http://lists.freepascal.org/lists/fpc-devel/2006-September/008737.html


Some things changed (e.g. TComponent.Loading has been added), but I stil 
did not find an easy way to fix lazarus bug 7305.


Looking at TReader.ReadComponent I have two questions:
First, why is for inline components csLoading set before the constructor 
is called and why for other components after the constructor is called.
Having csLoading set before the constructor would help me to decide to 
set the default values for the collection or not.


Secondly, why isn't TComponent.Loading called to set the csLoading flag? 
That way it could have been override by component, that needs a 
different state when loading than when just created. Or for what other 
purposes is TComponent.Loading made virtual? IIRC Graeme just needed it 
protected so he could call it.


Vincent
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Graeme Geldenhuys
2008/7/9 Craig Peterson <[EMAIL PROTECTED]>:
> Yes it is, and you must not be on the beta list. ;-)  V3 is in public beta
> and the Linux port is already available.  We're currently using Kylix, but
> we're looking into swapping out the compiler for FPC first, with a
> transition from CLX to LCL sometime later.

My day is just getting better, Thanks Craig! :-)  I'll try and
download the beta now. I'm a Linux junkie, but there are 3 Windows
products I can't do without. Beyond Compare 2, Total Commander and
PINS.  Hopefully soon, that will be down to only 2 Windows products.
;-)

Keep up the good work!

Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Craig Peterson

Is this Scooter Software that brought the awesome Beyond Compare 2 to
Windows users?  If so, I sure hope the query is because work on BC
2.xx or 3.x involves other platforms like Linux. ;-)


Yes it is, and you must not be on the beta list. ;-)  V3 is in public 
beta and the Linux port is already available.  We're currently using 
Kylix, but we're looking into swapping out the compiler for FPC first, 
with a transition from CLX to LCL sometime later.


http://www.scootersoftware.com/beta3/

Regards,
Craig Peterson
Scooter Software


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Graeme Geldenhuys
2008/7/9 Craig Peterson <[EMAIL PROTECTED]>:
> Thanks,
> Craig Peterson
> Scooter Software

Is this Scooter Software that brought the awesome Beyond Compare 2 to
Windows users?  If so, I sure hope the query is because work on BC
2.xx or 3.x involves other platforms like Linux. ;-)

If not, it's ok, BC2 works very nice via Linux + WINE.

Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] assigning a local function to a var

2008-07-09 Thread Chris Cheney
> I'd like to store an address of a local function in a variable, and
> call that local function, but I don't know how to define a variable of
> type "local function". Here's the error I'm stuck on, with sample
> code: 

"One can assign the following values to a procedural type variable:
1. Nil, for both normal procedure pointers and method pointers.
2. A variable reference of a procedural type, i.e. another variable of 
the same type.
3. A global procedure or function address, with matching function or 
procedure header and calling
convention.
4. A method address."

[reference manual
ftp://ftp.freepascal.org/pub/fpc/docs-pdf/ref.pdf
page 38]

Note "A GLOBAL procedure or function ... "

This is for a reason - think what would happen if you were able to a 
local procedure to a global variable!

FWIW the same is true of Delphi.

HTH
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Giulio Bernardi

Felipe Monteiro de Carvalho ha scritto:

On Wed, Jul 9, 2008 at 2:20 PM, Michael Van Canneyt
<[EMAIL PROTECTED]> wrote:

All targets in 2.3.1 now support {$R file} syntax.


So I assume we have a cross-platform resource compiler now, so is
windres unnecessary? Was pre-processing also implemented?


No. To compile .rc files to .res you still need windres. In general you 
can compile and run it fine on little endian machines, but it doesn't 
work (at least, it didn't work 6 months ago, don't know if newer 
versions are endian safe) on big endian machines.
So there is still no .rc compiler. However the 2.3.1 fpcres is able to 
compile dfm/lfm/xfm files.




Also, how do you access the resources? With TResourceStream?


With RTL functions like FindResource, LoadResource and so on. 
TResourceStream uses these functions.


Giulio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Felipe Monteiro de Carvalho
On Wed, Jul 9, 2008 at 2:20 PM, Michael Van Canneyt
<[EMAIL PROTECTED]> wrote:
> All targets in 2.3.1 now support {$R file} syntax.

So I assume we have a cross-platform resource compiler now, so is
windres unnecessary? Was pre-processing also implemented?

Also, how do you access the resources? With TResourceStream?

thanks,
-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] assigning a local function to a var

2008-07-09 Thread Joao Morais

David Emerson wrote:

   var
  // what should this be??
  my_func : function (pass_str : ansistring) : boolean;


Declare a new type:

type
  tmy_func = function(pass_str: ansistring): boolean;

var
  my_func: tmy_func;

Joao Morais
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Michael Van Canneyt


On Wed, 9 Jul 2008, Craig Peterson wrote:

> Does any version of FPC support the {$R file} syntax for resources on
> non-Windows targets?  I'd prefer that to Lazarus's LResources unit.  I have
> the impression that some work on it was done as part of Simon Kissel's
> CrossFPC project, but I haven't been able to verify that.  Was work done and
> never completed?  Is it a TODO that just doesn't have anyone to work on it?

All targets in 2.3.1 now support {$R file} syntax.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] assigning a local function to a var

2008-07-09 Thread Lourival Mendes
I'm not sure, but you could use TProcedure, some think like this:

procedure test;

   function func_a (pass_str : ansistring) : boolean;
  begin
 writeln (pass_str, 'A');
 func_a := true;
  end;

   function func_b (pass_str : ansistring) : boolean;
  begin
 writeln (pass_str, 'B');
 func_b := false;
  end;

   var
  // TProcedure
  my_func : TProcedure
  result: boolean ;

   begin
 my_func:= nil ;

 if not Assigned(my_func) then begin

my_func:= TProcedure(@func_a);
result:= my_func('hello, ');
   end
   else begin .

end;

end;

Try it and let me know...


Lourival Mendes

2008/7/9 David Emerson <[EMAIL PROTECTED]>:
> I'd like to store an address of a local function in a variable, and call
> that local function, but I don't know how to define a variable of
> type "local function". Here's the error I'm stuck on, with sample code:
>
> Error: Incompatible types:
> got ""
> expected " function(AnsiString):Boolean;Register>"
>
>
> procedure test;
>
>   function func_a (pass_str : ansistring) : boolean;
>  begin
> writeln (pass_str, 'A');
> func_a := true;
>  end;
>
>   function func_b (pass_str : ansistring) : boolean;
>  begin
> writeln (pass_str, 'B');
> func_b := false;
>  end;
>
>   var
>  // what should this be??
>  my_func : function (pass_str : ansistring) : boolean;
>
>   begin
>  my_func := @func_a;
>  my_func('hello, ');
>   end;
>
> Thanks!
> ~David.
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- 
Lourival J. Mendes Neto
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] {$R file} support on non-Windows targets

2008-07-09 Thread Craig Peterson
Does any version of FPC support the {$R file} syntax for resources on 
non-Windows targets?  I'd prefer that to Lazarus's LResources unit.  I 
have the impression that some work on it was done as part of Simon 
Kissel's CrossFPC project, but I haven't been able to verify that.  Was 
work done and never completed?  Is it a TODO that just doesn't have 
anyone to work on it?


Thanks,
Craig Peterson
Scooter Software

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] assigning a local function to a var

2008-07-09 Thread David Emerson
I'd like to store an address of a local function in a variable, and call 
that local function, but I don't know how to define a variable of 
type "local function". Here's the error I'm stuck on, with sample code:

Error: Incompatible types:
got ""
expected ""


procedure test;

   function func_a (pass_str : ansistring) : boolean;
  begin
 writeln (pass_str, 'A');
 func_a := true;
  end;

   function func_b (pass_str : ansistring) : boolean;
  begin
 writeln (pass_str, 'B');
 func_b := false;
  end;

   var
  // what should this be??
  my_func : function (pass_str : ansistring) : boolean;

   begin
  my_func := @func_a;
  my_func('hello, ');
   end;

Thanks!
~David.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Performance issue with dynamic arrays

2008-07-09 Thread Volker Zipfel
Hi all!

While analyzing my project with valgrind, I discovered that almost a quarter 
of the cpu cycle where eaten up by the function fpc_finalize_array. It seams 
that fpc_finalize_array calls for every element of the array fpc_finalize. To 
illustrate the problem i have written to small test programs:


program DynArray;
{$mode objfpc}{$H+}
var
 i: Integer;
 aArray: Array of Integer;
begin
 SetLength(aArray, 100);
 for i := 0 to 99 do
   aArray[i] := i;
 aArray := nil;
end.  
program StaticArray;
{$mode objfpc}{$H+}
var
 i: Integer;
 aArray: PIntegerArray;
begin
 GetMem(aArray, 100);
 for i := 0 to 99 do
   aArray^[i] := i;
 FreeMem(aArray);
end.
According to valgrind:

Total CPU cycles:
 DynArray: 32 243 842
 StaticArray: 2 107 419

And in the last line (aArray := nil; / FreeMem(aArray);):
 DynArray: 22 001 122
 StaticArray: 0

In order to avoid the unnecessary calls to fpc_finalize i added the following 
line to  fpc_finalize_array:

begin
 if PByte(typeinfo)^ in [tkAstring, tkWstring, tkArray, tkObject, tkRecord, 
tkInterface, tkDynArray, tkVariant] then   ...

After that i go:

Total CPU cycles - DynArray: 8 205 710.

As far as  I can see this change doesn't cause memory leaks.


Regards Volker

P.S.: I'm using rc_2_2_2.
Index: rtl/inc/rtti.inc
===
--- rtl/inc/rtti.inc	(Revision 11340)
+++ rtl/inc/rtti.inc	(Arbeitskopie)
@@ -339,7 +339,8 @@
   var
  i : longint;
   begin
- for i:=0 to count-1 do
-   int_finalize(data+size*i,typeinfo);
+ if PByte(typeinfo)^ in [tkAstring, tkWstring, tkArray, tkObject, tkRecord, tkInterface, tkDynArray, tkVariant] then 
+   for i:=0 to count-1 do
+ int_finalize(data+size*i,typeinfo);
   end;
 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Re: Ports unit on x64 Linux port

2008-07-09 Thread Felipe Monteiro de Carvalho
On Tue, Jul 8, 2008 at 5:17 PM, Vladimir Karpenko <[EMAIL PROTECTED]> wrote:
> Well WritePortB is in x86 unit? which is abscent in X86_64 port:(
> I wonder if some one can write in x64 asm program like this:
> MOV DX,0378H
>
> MOV AL,data //data - char.
>
> OUT DX,AL

I think yes, it should work in linux if you use ioperm.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Error during creation of DEB package on Ubuntu

2008-07-09 Thread Roland Turcan
Hello FPC-Pascal,

I have tried to build DEB package from latest snapshot and I've got
this result:

dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i -- -Z bzip2
dpkg-deb: building package `fpc' in `../fpc_2.3.1-20080709_all.deb'.
dpkg-deb: building package `fpc-source' in 
`../fpc-source_2.3.1-20080709_all.deb'.
dpkg-deb: building package `fp-docs' in `../fp-docs_2.3.1-20080709_all.deb'.
make[1]: Leaving directory `/usr/lib/lazarus/fpcbuild/build/fpc-2.3.1'
 dpkg-genchanges  >../fpc_2.3.1-20080709_i386.changes
dpkg-genchanges: including full source code in upload
dpkg-buildpackage: full upload; Debian-native package (full source is included)
mv -v -t . 
/usr/lib/lazarus/fpcbuild/build/fpc-2.3.1/../*.{deb,dsc,changes,tar.gz}
mv: cannot stat 
`/usr/lib/lazarus/fpcbuild/build/fpc-2.3.1/../*.{deb,dsc,changes,tar.gz}': No 
such file or directory
make: *** [debbuild] Error 1

-- 
Best regards, TRoland
http://www.rotursoft.sk
http://exekutor.rotursoft.sk

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal