Sign in Join

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

Mailing lists / lazarus / 1999-05

bit fields

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Sergio A. Kessler
to Peter Vreman: I've checked how C does the bitfields. But C (and also used in gtk) are things like:…
Show quoted text 9 lines
I've checked how C does the bitfields. But C (and also used in gtk) are things like: guint border_width : 3 Thus 3 bits! Which isn't a boolean, but a integer. > I was thinking of building support for it in the compiler, but only in the load/store(=assignment) nodes. So it doesn't work with inc(bitfield)

that would be really good.

btw, Peter, I've checked bindings for others languajes and what they do, is not translate the records (structs) of the objects, then transforming the object in a opaque object (wich is good), so then they provide accesors for the fields.
Something like this can be done ?

because I think we have a problem with certain functions, for example in notebook we have:

function  show_border()    // pretty generic name
wich does the work of gtk_notebook_get_show_border() // wich don't exist
then it should be:
function  gtk_notebook_show_border()
or better:
function  gtk_notebook_get_show_border()

or something like that, no ?

Sergio

Reply by email

Sergio Kessler

Hi all, I have been talking with the gtk developers to modify some things in the next release, so it easy for bindings makers to do the wrapers.
They are agreeing in some things (fields accesors for reading properties, at least implemented by macros), but when I mention that they should try to avoid to do guint bitfield : 1
they say me that this should be mapped to a boolean pascal, I don't think this is possible, it is ?

I get lost with this:

Pascal C

  entry_change_id : guint;    > 32 bits <     guint entry_change_id;
  list_change_id : guint;     > 32 bits <     guint list_change_id
  flag0 : word;                          /    guint value_in_list : 1;
                     \                 /      guint ok_if_empty : 1;
32b vs. 5b ?< guint case_sensitive : 1;
                                       \      guint use_arrows : 1;
                                         \    guint use_arrows_always : 1;
  current_button : guint16;   > 16 bits <     guint16 current_button;
  activate_id : guint;        > 32 bits <     guint activate_id;

When I pass an object to gtk, I pass a binary structure, how the remaining 27 bits of flag0 aren't overwrited with the next field (current_button) ??
The C compiler pack all this bits in a word, not byte, not anything else ?

It should help if they use something like:

typedef enum { 0, 1} gbit; ??
or
typedef enum { FALSE, TRUE} gbit; ??

Sergio

| Sergio A. Kessler http://perio.unlp.edu.ar/~sergio -O_O- Keep working at it... you will either succeed, or become an expert.

Reply by email

Peter Vreman
to Sergio Kessler
Show quoted text 8 lines
Hi all, I have been talking with the gtk developers to modify some things in the next release, so it easy for bindings makers to do the wrapers. They are agreeing in some things (fields accesors for reading properties, at least implemented by macros), but when I mention that they should try to avoid to do guint bitfield : 1 they say me that this should be mapped to a boolean pascal, I don't think this is possible, it is ?

I've checked how C does the bitfields. But C (and also used in gtk) are things like:

guint border_width : 3

Thus 3 bits! Which isn't a boolean, but a integer.

I was thinking of building support for it in the compiler, but only in the load/store(=assignment) nodes. So it doesn't work with inc(bitfield)

Peter

Reply by email

Peter Vreman
to Peter Vreman
you wrote 30 lines
>I've checked how C does the bitfields. But C (and also used in gtk) are >things like: > >guint border_width : 3 > >Thus 3 bits! Which isn't a boolean, but a integer. >> >I was thinking of building support for it in the compiler, but only in the >load/store(=assignment) nodes. So it doesn't work with inc(bitfield) that would be really good. btw, Peter, I've checked bindings for others languajes and what they do, is not translate the records (structs) of the objects, then transforming the object in a opaque object (wich is good), so then they provide accesors for the fields. Something like this can be done ? because I think we have a problem with certain functions, for example in notebook we have: function show_border() // pretty generic name wich does the work of gtk_notebook_get_show_border() // wich don't exist then it should be: function gtk_notebook_show_border() or better: function gtk_notebook_get_show_border() or something like that, no ?

The generic name doesn't matter because with the overloading there is no problem, and show_border is the field name in the record. To use gtk_notebook_ prefix will confuses with gtk procedures.

Reply by email

Sergio A. Kessler
to Peter Vreman
Show quoted text 12 lines
>function show_border() // pretty generic name >wich does the work of gtk_notebook_get_show_border() // wich don't exist > >then it should be: >function gtk_notebook_show_border() >or better: >function gtk_notebook_get_show_border() > >or something like that, no ? The generic name doesn't matter because with the overloading there is no problem, and show_border is the field name in the record. To use gtk_notebook_ prefix will confuses with gtk procedures.

it will not confuse, it just another accesor for a field of the struct

there is no show_border field name (because is a bit field)

check the notebook.pp example and you will see how this is used in a bad generic way.

Sergio

Reply by email