Send fpc-pascal mailing list submissions to
fpc-pascal@lists.freepascal.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
or, via email, send a message with subject or body 'help' to
fpc-pascal-requ...@lists.freepascal.org
You can reach the person managing the list at
fpc-pascal-ow...@lists.freepascal.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of fpc-pascal digest..."
Today's Topics:
1. Strange error (Hans M?rtensson)
2. Re: Records as properties and Delphi compiler error
(fpcl...@silvermono.co.za)
3. RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM (Henrik Genssen)
4. RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM (Henrik Genssen)
5. Re: Records as properties and Delphi compiler error
(Graeme Geldenhuys)
6. Re: Strange error (Vincent Snijders)
7. Re: Records as properties and Delphi compiler error
(fpcl...@silvermono.co.za)
8. Re: Records as properties and Delphi compiler error
(Martin Friebe)
----------------------------------------------------------------------
Message: 1
Date: Mon, 08 Jun 2009 18:12:11 +0200
From: Hans M?rtensson <cirkulat...@maartensson.net>
Subject: [fpc-pascal] Strange error
To: Free Pascal mailing list <fpc-pascal@lists.freepascal.org>
Message-ID: <4a2d385b.9040...@maartensson.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
When compiling a windows program with FPC version 2.2.4 with the switch
-dDEBUG (using the default configuration), after running the program I
get the following message:
-----------------------------
Error
Heap dump by heaptrc unit
0 memory blocks allocated: 0/0
0 memory blocks freed: 0/0
0 unfreed memory blocks: 0
True heap size: 65536 (80 used in System startup)
True free heap: 65456
-------------------------------
Is this:
-A joke?
-An error in the error message?
-Indicationg some problem with my program? and if so, how can I find it?
regards
Hans Maartensson
------------------------------
Message: 2
Date: Mon, 8 Jun 2009 19:02:00 +0200
From: fpcl...@silvermono.co.za
Subject: Re: [fpc-pascal] Records as properties and Delphi compiler
error
To: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Message-ID: <200906081902.01105.fpcl...@silvermono.co.za>
Content-Type: text/plain; charset="iso-8859-1"
On Sunday 07 June 2009 22:19:47 Jonas Maebe wrote:
On 07 Jun 2009, at 10:35, fpcl...@silvermono.co.za wrote:
A high level, a class is like a record that has been modified to
include
functions and procedures. I know that I'm over simplifying thing
here, please
bare with me.
The difference you skip over is the fundamental reason why one works
and the other doesn't: a class is a pointer, while a record is a value.
I understand the difference, but a pointer to a record still suffers the from
the same problem as a pointer to a class i.e. if memory is not allocated then
the code fails at runtime. It's interesting to note though, that Delphi allows
the assignment to the fields of a record type property via the with - do
construct. Is this also the case with FPC 2.3.1?
I'm trying to understand the logic employed by the creators of
Delphi where
they don't allow to write to the fields of a record type property,
but if the
property points to a class type, then anything goes.
In case of a class, the property returns a pointer (namely the pointer
to the class instance data), and then you (implicitly) dereference the
pointer and write data where it points to. In case of a record, the
property returns a record's value, and then (semantically) you change
the value of this returned record (not the value of the element of the
record that the property referred to).
This worked in previous FPC versions because rather than treating the
result of the property like a function result (which it has to,
because that's the semantical meaning of a property, so you can
transparently change them into getters/setters without breaking any
code), it treated it like a direct field access in case no getter/
setter existed. So rather than returning a record's value, the
property returned "a reference to a record".
In the example bellow,
where a property is of a class type, both Delphi and FPC compile the
code,
but there is no guarantee that the object referenced to by the
property has
been instantiated before the property is used (The programmer must
instantiate the TTestProp class within TTestClass prior to any call
made to xx
the property). IMO, it would be a nice feature if the compiler could
be
modified to issue a warning in such a case.Again, I'm over
simplifying, to
the compiler, it would be similar to checking for a variable
declaration
before the variable is used.
Except that it's about dynamically allocated memory and depends on
interprocedural control flow graph analysis, which makes it immensely
more complex.
I thing that the "error" in the way that FPC allows record
properties to
access the record fields could be handy if retained. Perhaps this
feature
could be reserved for objfpc mode. What are your thoughts on the
matter?
Things will remain the way they are for the reasons explained above.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
------------------------------
Message: 3
Date: Mon, 8 Jun 2009 18:16:16 +0200
From: "Henrik Genssen" <henrik.gens...@mediafactory.de>
Subject: RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM
To: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Message-ID: <4812dadfe9224179826f9a472c8f7...@nike>
Content-Type: text/plain; charset="iso-8859-1"
no, I did not know that.
Thanx for the hint - but its stuck to QT :-(
therefor I am more interested in gecko...
reply to message:
date: 24.05.2009 15:15:50
from: "Den Jean" <den.j...@telenet.be>
to: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
subject: Re: [fpc-pascal] Gecko / Firefox / XPCOM
On Thursday 21 May 2009 22:34:52 Henrik Genssen wrote:
I am trying to use the gecko libs from
http://sourceforge.net/projects/d-gecko with lazarus.
in case you didn't know
http://lists.lazarus.freepascal.org/pipermail/qt/2009-May/001212.html
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
------------------------------
Message: 4
Date: Mon, 8 Jun 2009 18:29:43 +0200
From: "Henrik Genssen" <henrik.gens...@mediafactory.de>
Subject: RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM
To: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
Message-ID: <a94be011b24244cd93c753d902c12...@nike>
Content-Type: text/plain; charset="iso-8859-1"
so how can this unit be converted to FPC,
as the Memorymanager of FPC seems to differ from delphi...
unit nsMemory;
{$MODE Delphi}
interface
uses
nsXPCOM;
const
NS_MEMORY_CONTRACTID = '@mozilla.org/xpcom/memory-service;1';
NS_MEMORY_CLASSNAME = 'Global Memory Service';
NS_MEMORY_CID: TGUID = '{30a04e40-38e7-11d4-8cf5-0060b0fc14a3}';
function Alloc(size: Integer): Pointer;
function Realloc(ptr: Pointer; size: Integer): Pointer;
function Free(ptr: Pointer): Integer;
function HeapMinimize(aImmediate: Boolean): Longword;
function Clone(Ptr: Pointer; size: Longword): Pointer;
function GetGlobalMemoryService: nsIMemory;
function GlueStartupMemory: Longword;
procedure GlueShutdownMemory;
procedure SetToMemoryManager;
implementation
uses
nsError, nsInit;
var
gMemory: nsIMemory;
procedure FreeGlobalMemory;
begin
gMemory := nil;
end;
function SetupGlobalMemory: nsIMemory;
begin
if Assigned(gMemory) then Exit;
nsInit.NS_GetMemoryManager(gMemory);
if not Assigned(gMemory) then Exit;
Result := gMemory;
end;
function GlueStartupMemory: Longword;
begin
Result := NS_ERROR_FAILURE;
if Assigned(gMemory) then Exit;
nsInit.NS_GetMemoryManager(gMemory);
if not Assigned(gMemory) then Exit;
Result := NS_OK;
end;
procedure GlueShutdownMemory;
begin
gMemory := nil;
end;
function ENSURE_ALLOCATOR: Boolean;
begin
Result := True;
if not Assigned(gMemory) and not Assigned(SetupGlobalMemory()) then
Result := False;
end;
function Alloc(size: Integer): Pointer;
begin
Result := nil;
if ENSURE_ALLOCATOR then
Result := gMemory.Alloc(size);
end;
function Realloc(ptr: Pointer; size: Integer): Pointer;
begin
Result := nil;
if ENSURE_ALLOCATOR then
Result := gMemory.Realloc(ptr, size);
end;
function Free(ptr: Pointer): Integer;
begin
Result := NS_OK;
if ENSURE_ALLOCATOR then gMemory.Free(ptr)
else
Result := Integer(NS_ERROR_UNEXPECTED);
end;
function HeapMinimize(aImmediate: Boolean): Longword;
begin
Result := NS_ERROR_FAILURE;
if ENSURE_ALLOCATOR then
try
Result := NS_OK;
gMemory.HeapMinimize(aImmediate);
except
Result := NS_ERROR_FAILURE;
end;
end;
function Clone(ptr: Pointer; size: Longword): Pointer;
begin
Result := nil;
if ENSURE_ALLOCATOR then
Result := Clone(Ptr, size);
end;
function GetGlobalMemoryService: nsIMemory;
begin
Result := nil;
if not ENSURE_ALLOCATOR then Exit;
Result := gMemory;
end;
const
memmgr: TMemoryManager = (
GetMem: Alloc;
FreeMem: Free;
ReallocMem: Realloc;
);
procedure SetToMemoryManager;
begin
SetMemoryManager(memmgr);
end;
end.
reply to message:
date: 24.05.2009 18:28:19
from: "Flávio Etrusco" <flavio.etru...@gmail.com>
to: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org>
subject: Re: [fpc-pascal] Gecko / Firefox / XPCOM
On Sun, May 24, 2009 at 9:30 AM, Jonas Maebe <jonas.ma...@elis.ugent.be> wrote:
On 21 May 2009, at 22:34, Henrik Genssen wrote:
nsMemory.pas(157,17) Error: Incompatible types: got "Realloc(Pointer,
LongInt):^untyped" expected "<procedure variable type of function(var
Pointer, LongInt):^untyped;Register>"
As the error message says: the compiler expects the first parameter of
realloc to be a "var" parameter, while the declaration of realloc apparently
uses a value parameter.
Jonas
Oops. I guess I assumed the code was the other way around: that the
gecko runtime accepted an application-provided mem-allocation
routines, and barely read the message :-$
BTW, regarding the remaining Warnings from the OP: is there any
optional member in TMemoryManager or do all of them need to be setup?
-Flávio
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
------------------------------
Message: 5
Date: Mon, 08 Jun 2009 19:55:00 +0200
From: Graeme Geldenhuys <grae...@opensoft.homeip.net>
Subject: Re: [fpc-pascal] Records as properties and Delphi compiler
error
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Message-ID: <4a2d5074.60...@opensoft.homeip.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Hi Nino,
Can you please refrain from quoting the *whole* previous message, when your
reply only relates to one or two lines. If other developers want to read the
whole context of the message thread they can look in their email history or the
mailing list archive.
It is REALLY annoying seeing 80 lines in a message and then only 3 of those
lines are actually the reply and the other 77 line are quoted text!