Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-02

more descriptive parameter names for C translated headers

7 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I use the xlib.pp unit a lot. As far as I understand it and many others like it was created with a automated tool. As I use the functions, I thought I could start changing the para1, para2... to more descriptive parameter names. This makes it much easier to code if you use something like Lazarus that gives function declaration hints etc..

It will not affect/break anybody's code if I start making those changes, but I would like to get the correct naming convention going... I'm only doing this once! :)

Here's the original declaration:

function XSetSelectionOwner(para1:PDisplay; para2:TAtom;
para3:TWindow; para4:TTime):cint;cdecl;external libX11;

what should the new parameters look like....

Delphi / standard Object Pascal style:

1)
function XSetSelectionOwner(ADisplay:PDisplay; ASelection:TAtom;
AOwner:TWindow; ATime:TTime):cint;cdecl;external libX11;

or maybe

2)
function XSetSelectionOwner(display:PDisplay; selection:TAtom;
owner:TWindow; time:TTime):cint;cdecl;external libX11;

My preference is 1). What's your thoughts?

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Mattias Gärtner
to Graeme Geldenhuys

Zitat von Graeme Geldenhuys :

Show quoted text 36 lines
Hi, I use the xlib.pp unit a lot. As far as I understand it and many others like it was created with a automated tool. As I use the functions, I thought I could start changing the para1, para2... to more descriptive parameter names. This makes it much easier to code if you use something like Lazarus that gives function declaration hints etc.. It will not affect/break anybody's code if I start making those changes, but I would like to get the correct naming convention going... I'm only doing this once! :) Here's the original declaration: function XSetSelectionOwner(para1:PDisplay; para2:TAtom; para3:TWindow; para4:TTime):cint;cdecl;external libX11; what should the new parameters look like.... Delphi / standard Object Pascal style: 1) function XSetSelectionOwner(ADisplay:PDisplay; ASelection:TAtom; AOwner:TWindow; ATime:TTime):cint;cdecl;external libX11; or maybe 2) function XSetSelectionOwner(display:PDisplay; selection:TAtom; owner:TWindow; time:TTime):cint;cdecl;external libX11; My preference is 1). What's your thoughts?

Parameter names are needed by many headers.
Why not write a tool, that does it semi-automatically? Give it the c file with nice parameter names and the pascal unit and it replaces para* with the c names.
This tool could be useful here:
http://wiki.lazarus.freepascal.org/Creating_bindings_for_C_libraries#Future_work_.2F_Missing_stuff

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gärtner
Mattias Gärtner wrote 10 lines
> > My preference is 1). What's your thoughts? Parameter names are needed by many headers. Why not write a tool, that does it semi-automatically? Give it the c file with nice parameter names and the pascal unit and it replaces para* with the c names. This tool could be useful here: http://wiki.lazarus.freepascal.org/Creating_bindings_for_C_libraries#Future_work_.2F_Missing_stuff

Interesting idea, I'll give it a go.

I might have asked this before, but why doesn't the h2pas tool put in the correct parameter names in the first place? I'm sure there must be some technical reason? :)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Felipe Monteiro de Carvalho
to Graeme Geldenhuys
Graeme Geldenhuys wrote
I might have asked this before, but why doesn't the h2pas tool put in the correct parameter names in the first place? I'm sure there must be some technical reason? :)

I think that h2pas just needs to be improved.

I took a look at the code while thinking about creating something similar for objective-c for the Cocoa bindings, but h2pas has a very exotic code. I think it's created with the gnu tools for automatic compiler generation, yacc. I read the code, but understood absolutely nothing =)

Felipe Monteiro de Carvalho

Reply by email

Mattias Gaertner
to Felipe Monteiro de Carvalho
Show quoted text 5 lines
On Feb 1, 2008 6:58 PM, Graeme Geldenhuys wrote: > I might have asked this before, but why doesn't the h2pas tool put > in the correct parameter names in the first place? I'm sure there > must be some technical reason? :)

It does. But some c libs only provide crappy c
headers.

Show quoted text 7 lines
I think that h2pas just needs to be improved. I took a look at the code while thinking about creating something similar for objective-c for the Cocoa bindings, but h2pas has a very exotic code. I think it's created with the gnu tools for automatic compiler generation, yacc. I read the code, but understood absolutely nothing =)

Mattias

Reply by email

Peter Vreman
to Graeme Geldenhuys: I use the xlib.pp unit a lot. As far as I understand it and many others like it was…
Graeme Geldenhuys wrote 34 lines
Hi, I use the xlib.pp unit a lot. As far as I understand it and many others like it was created with a automated tool. As I use the functions, I thought I could start changing the para1, para2... to more descriptive parameter names. This makes it much easier to code if you use something like Lazarus that gives function declaration hints etc.. It will not affect/break anybody's code if I start making those changes, but I would like to get the correct naming convention going... I'm only doing this once! :) Here's the original declaration: function XSetSelectionOwner(para1:PDisplay; para2:TAtom; para3:TWindow; para4:TTime):cint;cdecl;external libX11; what should the new parameters look like.... Delphi / standard Object Pascal style: 1) function XSetSelectionOwner(ADisplay:PDisplay; ASelection:TAtom; AOwner:TWindow; ATime:TTime):cint;cdecl;external libX11; or maybe 2) function XSetSelectionOwner(display:PDisplay; selection:TAtom; owner:TWindow; time:TTime):cint;cdecl;external libX11; My preference is 1). What's your thoughts?

You can improve the source. It is just a name and not used for anything else because it is an external.

Peter

Reply by email

Micha Nelissen
to Graeme Geldenhuys: I use the xlib.pp unit a lot. As far as I understand it and many others like it was…
Graeme Geldenhuys wrote 11 lines
1) function XSetSelectionOwner(ADisplay:PDisplay; ASelection:TAtom; AOwner:TWindow; ATime:TTime):cint;cdecl;external libX11; or maybe 2) function XSetSelectionOwner(display:PDisplay; selection:TAtom; owner:TWindow; time:TTime):cint;cdecl;external libX11; My preference is 1). What's your thoughts?

Usually the rule is: 'he who does the work decides'.

Have fun ;)

Micha

Reply by email