Re: [fpc-pascal]FPC Version 1.9.4 released.

2004-06-04 Thread Olle Raab
04-06-02 15.39, skrev James Mills följande:

> On Wed, Jun 02, 2004 at 03:40:38PM +0200, Michael Van Canneyt wrote:
>>> And PIC (Position Independant Code) generation is working too ?
>> 
>> No. See the roadmap: scheduled for 1.9.6
> 
> Excuse me ignorance. I don't beleive I know what PIC is... What is PIC ?

In OS's like unix (dont know about windows/dos) the machine code has
absolute adresses. This works because there is a virtual address space for
each process. But if a shared library is used, it cannot use absolute
addressing, since othersise it might collide with another shared library.
Hence it has to be independant of where in memory it is loaded. And data has
to be accessed relative the program counter. Code with this property is PIC.

Olle


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Am Fr, den 04.06.2004 schrieb Peter Vreman um 08:46:
[...]
> Without a full (short) example we can't do anything.

See below, I've tried to cut down the size without loosing to much
information this time ...

> > And why it worked fine on the 1.0.10 version of fpc?
> 
> 1.9.2 uses register calling by default.

I don't get that. Do you say it worked by accident?

The code:

unit StateInput;

{$define debug}

interface

...
procedure setCustDataCallback(data: TCustomer);  cdecl;
...


implementation
procedure setCustDataCallback(data: TCustomer); cdecl;
begin
writeln('Name is '+_data.Name);
with _data do begin
if (Name <> '') then gtk_entry_set_text(_me.entries[0], pchar(@Name));
if (FirstName <> '') then gtk_entry_set_text(_me.entries[1], 
pchar(@FirstName));

...
end;

procedure showCustomerBrowser(btn: pGtkButton; data: gpointer); cdecl;
var
ds: TDataSource;
begin
writeln('SI: showCustomerBrowser start');
if not(DBMan=NIL) then ds := DBMan.customers else writeln('SI: DBMan=NIL!');
br := TCustomerBrowser.create(ds, @setCustDataCallback);
writeln('SI: browser created');
br.execute;
end;

-

unit CustomerBrowser;

type
TPropagateCallback = procedure(data: TCustomer);

TCustomerBrowser = class
public
dialog: pGtkWidget; { access for caller granted }

constructor create(data: TDataSource; callback: TPropagateCallback);
destructor destroy; override;
function execute: boolean;
private
btnOkay: pGtkWidget;
btnCancel: pGtkWidget;
headline: pGtkWidget;
scroll: pGtkWidget;
list: pGtkWidget;
procedure fillCustomerList(l: pGtkCList);
end;

procedure onCustOkay(data : pGtkCList ); cdecl;

var { should be props, doesn't work with callbacks }
cbPropagate : TPropagateCallback;
...
implementation

constructor TCustomerBrowser.create(data: TDataSource; callback: TPropagateCallback);
begin
inherited create;
_creating := TRUE;

cbPropagate := callback;
...
end;

procedure onCustOkay(data : pGtkCList ); cdecl;
var
src: TCustomer;
dlg: pGtkDialog;
btnOk: pGtkWidget;
(*towait, remain : timespec;*)
begin
if (selCursor > -1) then begin

{ fetch selected entry }
selCursor := datasrc.indexOfID(selCursor);
gtk_clist_set_auto_sort(data, FALSE);
src := TCustomer(datasrc.Items[selCursor]);
{$ifdef debug} writeln(src.asCSV); {$endif}

{ propagate selected entry }
cbPropagate(src);

gtk_widget_destroy(_me);
...
end;



unit CommonTypes;

interface
...
type
TCustomerClass = class of TCustomer;
TCustomer = class(TStorable)
Name: AnsiString;
FirstName: AnsiString;
Street: AnsiString;
Zip: Ansistring;
City: AnsiString;
...
function asCSV: AnsiString; override;
procedure fillFromCSV(csv: AnsiString); override;
class function getHeaderString: AnsiString; override; { first line of 
CSV format }
end;

const
SEP: char = ';';
QT: char = '"';

implementation

function TCustomer.asCSV: AnsiString;
begin
result :=   IntToStr(ID) +
SEP + QT + Name + QT +
SEP + QT + FirstName + QT +
SEP + QT + Street + QT +
SEP + QT + ZIP + QT +
SEP + QT + City + QT +
SEP + QT + Phone + QT +
...
{$ifdef debug}writeln('CT:customer.asCSV:'+result);{$endif}
end;
-

I hope there is a solution. As written, the TCustomer item "src" should
be handed over to the code calling the browser dialog and it's zero any
time in the callback in the first unit.

Writing out it's content in the code that makes the call to the callback
with "asCSV" works okay, the contained information is correct.

Marc




___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Peter Vreman
>> Without a full (short) example we can't do anything.
>
> See below, I've tried to cut down the size without loosing to much
> information this time ...
>
>> > And why it worked fine on the 1.0.10 version of fpc?
>>
>> 1.9.2 uses register calling by default.
>
> I don't get that. Do you say it worked by accident?

Possibly, 1.0.10 uses a different calling convention that looks more like
cdecl.


> The code:
> 

Sorry, but is still useless because it can't be compiled. Only full
working (easy to build and run) short examples help.

Try to isolate the problem in a smaller program.



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Am Fr, den 04.06.2004 schrieb Peter Vreman um 17:54:
> >> Without a full (short) example we can't do anything.
> >
> > See below, I've tried to cut down the size without loosing to much
> > information this time ...
> >
> >> > And why it worked fine on the 1.0.10 version of fpc?
> >>
> >> 1.9.2 uses register calling by default.
> >
> > I don't get that. Do you say it worked by accident?
> 
> Possibly, 1.0.10 uses a different calling convention that looks more like
> cdecl.

Maybe that was the cause for the un detectable 'internal error' problem
with 1.01.10 that made me switch to 1.9 ...

> 
> > The code:
> > 
> 
> Sorry, but is still useless because it can't be compiled. Only full
> working (easy to build and run) short examples help.
> 
> Try to isolate the problem in a smaller program.

Okay, I'm coming back on this asap.

Thank so far,
Marc



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Here it is (as attachment, hopefully the list processor doesn't strip it
off):


unit browser192;

{$define debug}
interface
uses sysutils, glib, gdk, gtk, unix;

const
SEP: char = ';';
QT: char = '"';

type
TCustomer = class
Name: AnsiString;
FirstName: AnsiString;
Street: AnsiString;
Zip: Ansistring;
City: AnsiString;
Phone: AnsiString;
function asCSV: AnsiString;
end;

TPropagateCallback = procedure(data: TCustomer);

CustomerBrowserClass = class of TCustomerBrowser;

TCustomerBrowser = class
public
dialog: pGtkWidget; { access for caller granted }

constructor create(callback: TPropagateCallback);
destructor destroy; override;
function execute: boolean;
private
btnOkay: pGtkWidget;
btnCancel: pGtkWidget;
headline: pGtkWidget;
scroll: pGtkWidget;
end;

procedure onCustOkay(data : pGtkCList ); cdecl;

var
cbPropagate : TPropagateCallback;
_me : pGtkWidget;

implementation


function TCustomer.asCSV: AnsiString;
begin
result := 
SEP + QT + Name + QT +
SEP + QT + FirstName + QT +
SEP + QT + Street + QT +
SEP + QT + ZIP + QT +
SEP + QT + City + QT +
SEP + QT + Phone + QT;
end;

procedure onCustOkay(data : pGtkCList ); cdecl;
var
src: TCustomer;
begin
src := TCustomer.create;
src.Name := 'The Name';
src.FirstName := 'FirstName';
{$ifdef debug} writeln(src.asCSV); {$endif}

{ propagate selected entry }
cbPropagate(src);

gtk_widget_destroy(_me);

end; { onCustOkay }

constructor TCustomerBrowser.create(callback: TPropagateCallback);
begin
inherited create;

cbPropagate := callback;

dialog := gtk_dialog_new();
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
gtk_window_set_position(pGtkWindow(dialog), GTK_WIN_POS_CENTER);
gtk_widget_set_usize(dialog, 500, 400);
gtk_container_set_border_width(pGTKCONTAINER(dialog), 24);
_me := dialog;

headline := gtk_label_new(PChar('Any Headline'));

gtk_box_pack_start( pGtkBox(GTK_DIALOG(dialog)^.vbox) , headline, FALSE, 
FALSE, 5);

{ --- button OK --- }
btnOkay := gtk_button_new_with_label('do call back');

{ transport data to caller via callback on 'OK' }
gtk_signal_connect_object (GTK_OBJECT (btnOkay), 'clicked',
GTK_SIGNAL_FUNC (@onCustOkay), nil);

gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)^.action_area),
btnOkay);

end;

destructor TCustomerBrowser.destroy;
begin
{ nothing yet }
end;

function TCustomerBrowser.execute: boolean;
begin
result := FALSE;
gtk_widget_show_all (dialog);
end;

END.
program main192;
{$mode objfpc}
uses sysutils, glib, gdk, gtk, browser192;

var
window : pGtkWidget;
c  : pGtkWidget;
br : TCustomerBrowser;


procedure destroy(widget : pGtkWidget ; data: pgpointer ); cdecl;
begin
if assigned(br) then br.free;
gtk_main_quit();
end;

procedure setCustDataCallback(data: TCustomer); cdecl;
begin
writeln('callback: Name is '+data.Name);
end;

procedure showCustomerBrowser(btn: pGtkButton; data: gpointer); cdecl;
begin
writeln('showCustomerBrowser start');
br := TCustomerBrowser.create(@setCustDataCallback);
writeln('browser created');
br.execute;
end;

BEGIN

gtk_init (@argc, @argv);

window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
c := gtk_button_new_with_label('show browser');
gtk_container_add(GTK_CONTAINER(window), c);
gtk_signal_connect(GTK_OBJECT(c), 'clicked',
   GTK_SIGNAL_FUNC(@showCustomerBrowser), NIL);

gtk_signal_connect (pGTKOBJECT(window), 'destroy',
GTK_SIGNAL_FUNC (@destroy), NULL);
gtk_widget_show_all(window);
gtk_widget_show (window);

gtk_main ();

END.

Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Peter Vreman
> Here it is (as attachment, hopefully the list processor doesn't strip it
> off):

1.9.4 reports:

main192.pp(25,52) Error: Incompatible type for arg no. 1: Got "", expected ""



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Am Fr, den 04.06.2004 schrieb Peter Vreman um 19:25:
> > Here it is (as attachment, hopefully the list processor doesn't strip it
> > off):
> 
> 1.9.4 reports:
> 
> main192.pp(25,52) Error: Incompatible type for arg no. 1: Got " procedure(TCustomer);CDecl>", expected " procedure(TCustomer);Register>"

Ah, I see. I'll change the declaration of the callback proc then.

I hope the version 1.9.4 is getting into the ports system of FreeBSD
soon, I got the port yesterday which is still at 1.9.2 (not that far
behind ;).

Maybe I can use the Linux emulation and use 1.9.4/Linux for error
detection immediately ...

Thank you very much, it helped a lot,
Marc



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marco van de Voort
> > 1.9.4 reports:
> > 
> > main192.pp(25,52) Error: Incompatible type for arg no. 1: Got " > procedure(TCustomer);CDecl>", expected " > procedure(TCustomer);Register>"
> 
> Ah, I see. I'll change the declaration of the callback proc then.
> 
> I hope the version 1.9.4 is getting into the ports system of FreeBSD
> soon, I got the port yesterday which is still at 1.9.2 (not that far
> behind ;).

Don't expect it too soon, it is quite some work, and worse, the time between
committing and submitting is quite long on avg.
 
> Maybe I can use the Linux emulation and use 1.9.4/Linux for error
> detection immediately ...

Or simply use the 1.9.4/freebsd release?


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Hi again,

oncemore for the sake of completeness:

The 1.9.2 version of fpc is buggy on FreeBSD.

I get various problems in a method of an object reading its own private
variables. Some do work, others don't. No scheme of finding out which
will.

There may be a coincidence with the order of the vars in the VMT (looks
as if the first one is the faulty one), but i cannot say so for sure.

I would really appreciate if this is fixed in 1.9.4.

Marc



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Am Fr, den 04.06.2004 schrieb Marco van de Voort um 21:45:
> > > 1.9.4 reports:
> > > 
> > > main192.pp(25,52) Error: Incompatible type for arg no. 1: Got " > > procedure(TCustomer);CDecl>", expected " > > procedure(TCustomer);Register>"
> > 
> > Ah, I see. I'll change the declaration of the callback proc then.
> > 
> > I hope the version 1.9.4 is getting into the ports system of FreeBSD
> > soon, I got the port yesterday which is still at 1.9.2 (not that far
> > behind ;).
> 
> Don't expect it too soon, it is quite some work, and worse, the time between
> committing and submitting is quite long on avg.
>  
> > Maybe I can use the Linux emulation and use 1.9.4/Linux for error
> > detection immediately ...
> 
> Or simply use the 1.9.4/freebsd release?

I've got to look for it, if it's a package this would be okay, but using
the installer made me search for files and tweaking paths and the like
for days, I can't afford something like that right now.

Thanks for pointing out,
Marc



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marco van de Voort
> oncemore for the sake of completeness:
> 
> The 1.9.2 version of fpc is buggy on FreeBSD.
> 
> I get various problems in a method of an object reading its own private
> variables. Some do work, others don't. No scheme of finding out which
> will.

Then it is probably a memory problem. I used 1.9.2 and 1.9.3 a lot, and never
noticed anything.
 
> There may be a coincidence with the order of the vars in the VMT (looks
> as if the first one is the faulty one), but i cannot say so for sure.

> I would really appreciate if this is fixed in 1.9.4.

It will be hard without code to reproduce it.

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Am Fr, den 04.06.2004 schrieb Marc Santhoff um 22:42:

> There may be a coincidence with the order of the vars in the VMT (looks
> as if the first one is the faulty one), but i cannot say so for sure.

Sorry, no VMT for vars, I meant the first one listed in the source
(displayed first in the debugger, too).

Marc



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]parameter is 0x0 on callback

2004-06-04 Thread Marc Santhoff
Am Fr, den 04.06.2004 schrieb Marco van de Voort um 22:54:
> > oncemore for the sake of completeness:
> > 
> > The 1.9.2 version of fpc is buggy on FreeBSD.
> > 
> > I get various problems in a method of an object reading its own private
> > variables. Some do work, others don't. No scheme of finding out which
> > will.
> 
> Then it is probably a memory problem. I used 1.9.2 and 1.9.3 a lot, and never
> noticed anything.

You're probably right with that. Debugging with stack checking impresses
me very much ... 

So i looked in the docs and asked myself:

What are the limits for stack and heap?
And why does the -Cs switch do nothing on Linux and FreeBSD?

Fact is, the stack is overflowing right at the start and i did not
notice.

Marc



___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal