Gecko / Firefox / XPCOM

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Gecko / Firefox / XPCOM

Henrik Genssen
Hi,

I am trying to use the gecko libs from  http://sourceforge.net/projects/d-gecko
with lazarus.

i get the following errors:
Hint: Start of reading config file c:\lazarus\fpc\2.2.2\bin\i386-win32\fpc.cfg
Hint: End of reading config file c:\lazarus\fpc\2.2.2\bin\i386-win32\fpc.cfg
Free Pascal Compiler version 2.2.2 [2008/10/05] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Win32 for i386
Compiling project1.lpr
Compiling SimpleDownloadForm.pas
Compiling nsGeckoStrings.pas
Compiling nsInit.pas
nsInit.pas(55,15) Hint: Type "PLongBool" redefinition
nsInit.pas(104,1) Hint: C arrays are passed by reference
nsInit.pas(233,27) Hint: Type "PGREVersionRangeArray" redefinition
nsInit.pas(241,23) Hint: Type "PGREPropertyArray" redefinition
Compiling nsMemory.pas
nsMemory.pas(155,13) Warning: Some fields coming before "GetMem" weren't initialized
nsMemory.pas(157,17) Warning: Some fields coming before "ReallocMem" weren't initialized
nsMemory.pas(157,17) Error: Incompatible types: got "Realloc(Pointer, LongInt):^untyped" expected "<procedure variable type of function(var Pointer, LongInt):^untyped;Register>"
nsMemory.pas(165) Fatal: There were 1 errors compiling module, stopping

for the following costruct - stopping at the line ReallocMem:

const
  memmgr: TMemoryManager = (
    GetMem: Alloc;
    FreeMem: Free;
    ReallocMem: Realloc;
  );
procedure SetToMemoryManager;
begin
  SetMemoryManager(memmgr);
end;

how can that be done in FPC?

regards

Hinnack
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Gecko / Firefox / XPCOM

etrusco
On Thu, May 21, 2009 at 5:34 PM, Henrik Genssen
<[hidden email]> wrote:

> (...)
> nsMemory.pas(155,13) Warning: Some fields coming before "GetMem" weren't initialized
> nsMemory.pas(157,17) Warning: Some fields coming before "ReallocMem" weren't initialized
> nsMemory.pas(157,17) Error: Incompatible types: got "Realloc(Pointer, LongInt):^untyped" expected "<procedure variable type of function(var Pointer, LongInt):^untyped;Register>"
> nsMemory.pas(165) Fatal: There were 1 errors compiling module, stopping
>
> for the following costruct - stopping at the line ReallocMem:
>
> const
>  memmgr: TMemoryManager = (
>    GetMem: Alloc;
>    FreeMem: Free;
>    ReallocMem: Realloc;
>  );
> procedure SetToMemoryManager;
> begin
>  SetMemoryManager(memmgr);
> end;
>
> how can that be done in FPC?
>
> regards
>
> Hinnack

You must either set Delphi compiler mode - {$mode Delphi} - or get a
reference/pointer to the functions Alloc, Free and Realloc (prefix
them with the @ operator).
BTW, it looks like you're accessing the TMemoryManager declaration
from System.pp/SysInit (? heaph.inc), is it what you intended?

Best regards,
Flávio
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Re: Gecko / Firefox / XPCOM

Henrik Genssen
>> (...)
>> nsMemory.pas(155,13) Warning: Some fields coming before "GetMem" weren't initialized
>> nsMemory.pas(157,17) Warning: Some fields coming before "ReallocMem" weren't initialized
>> nsMemory.pas(157,17) Error: Incompatible types: got "Realloc(Pointer, LongInt):^untyped" expected "<procedure variable type of function(var Pointer, LongInt):^untyped;Register>"
>> nsMemory.pas(165) Fatal: There were 1 errors compiling module, stopping
>>
>> for the following costruct - stopping at the line ReallocMem:
>>
>> const
>>  memmgr: TMemoryManager = (
>>    GetMem: Alloc;
>>    FreeMem: Free;
>>    ReallocMem: Realloc;
>>  );
>> procedure SetToMemoryManager;
>> begin
>>  SetMemoryManager(memmgr);
>> end;
>You must either set Delphi compiler mode - {$mode Delphi} - or get a
>reference/pointer to the functions Alloc, Free and Realloc (prefix
>them with the @ operator).
I have already set the compilermode to Delphi - any other idea?

>BTW, it looks like you're accessing the TMemoryManager declaration
>from System.pp/SysInit (? heaph.inc), is it what you intended?
in Delphi system.pas is used:

  PMemoryManager = ^TMemoryManager;
  TMemoryManager = record
    GetMem: function(Size: Integer): Pointer;
    FreeMem: function(P: Pointer): Integer;
    ReallocMem: function(P: Pointer; Size: Integer): Pointer;
  end;

what shell I use with FPC?

regards

Hinnack
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Gecko / Firefox / XPCOM

Jonas Maebe-2
In reply to this post by Henrik Genssen

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Gecko / Firefox / XPCOM

Den Jean
In reply to this post by Henrik Genssen
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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Gecko / Firefox / XPCOM

etrusco
In reply to this post by Jonas Maebe-2
On Sun, May 24, 2009 at 9:30 AM, Jonas Maebe <[hidden email]> 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  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Re: Gecko / Firefox / XPCOM

Henrik Genssen
In reply to this post by Den Jean
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" <[hidden email]>
>to: "FPC-Pascal users discussions" <[hidden email]>
>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  -  [hidden email]
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Re: Gecko / Firefox / XPCOM

Henrik Genssen
In reply to this post by etrusco
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" <[hidden email]>
>to: "FPC-Pascal users discussions" <[hidden email]>
>subject: Re: [fpc-pascal] Gecko / Firefox / XPCOM
>
>On Sun, May 24, 2009 at 9:30 AM, Jonas Maebe <[hidden email]> 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  -  [hidden email]
>http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Documentation for the UTF-8 Functions

David Copeland
In reply to this post by Henrik Genssen
Can anyone point me to where the utf-8 functions are documented? I have
tried looking in the docs for the RTL but could not find them.

Thanks,
Dave.



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal