Sign in Join

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

Mailing lists / fpc-pascal / 2002-11

method pointers, design patterns, OP idioms etc.

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

V.Krishnakumar

Hi group !,

I'm a complete newbie (although I've been having the FPC tree for almost a year !).

I've a few questions:

1. Is method pointers supported ? If so can anyone provide me with some examples of usage.

2. web pointers to idioms, design patterns etc. (I'm googling ....) In particular I'm looking for the observer pattern implementation without using interfaces.

3. I wrote a memory manager interface to the Boehm GC library. It compiled fine but crashed during the 'mark' phase of the collection. I think I can fix the problem by explicitly adding the root pointers for the collector for which I need to find the absolute addresses of the data and bss segments. Anybody knows how to get this ? (the binutils generate labels __data_start and __bss_start for C programs. But code generated by FPC only has __bss_start.)

Sorry for the long msg !,

thx in advance,
-Krish

Unknown author
I've a few questions: 1. Is method pointers supported ? If so can anyone provide me with some examples of usage.

Yes.

type
  MyMethodPointer = procedure(Sender: TObject) of object;
  MyclassWithMethodPointer = class
  private
    FMethodPointer: MyMethodPointer;
  public
    property MethodPointer: MyMethodPointer
      read FMethodPointer write FMethodPointer;
  end;
2. web pointers to idioms, design patterns etc. (I'm googling ....) In particular I'm looking for the observer pattern implementation without using interfaces.

This one is more tricky. Can't help you there.

Show quoted text 6 lines
3. I wrote a memory manager interface to the Boehm GC library. It compiled fine but crashed during the 'mark' phase of the collection. I think I can fix the problem by explicitly adding the root pointers for the collector for which I need to find the absolute addresses of the data and bss segments. Anybody knows how to get this ? (the binutils generate labels __data_start and __bss_start for C programs. But code generated by FPC only has __bss_start.)

Without seeing your code it is impossible to comment with any authority. It sounds like you're making things overly compilcated though. If it works in C without this information then you probably don't need it. Otherwise, you could try writing a small routine to return the correct information to Pascal and add it to the library.

Hope that helps,

Matt

---------------------------------------------
This message was sent using Mistral WebMail.
http://www.mistral.co.uk/

Marco van de Voort
to Unknown author
> particular I'm looking for the observer pattern implementation without using > interfaces. This one is more tricky. Can't help you there.

I wouldn't do this anyway, since the FPC version in development already supports interfaces. (and is generally usable, though it can be broken from time to time. So always back up your last working snapshot)

V.Krishnakumar
you wrote 15 lines
From: > 3. I wrote a memory manager interface to the Boehm GC library. It > compiled fine but crashed during the 'mark' phase of the collection. I > think I can fix the problem by explicitly adding the root pointers for > the collector for which I need to find the absolute addresses of the data > and bss segments. Anybody knows how to get this ? (the binutils generate > labels __data_start and __bss_start for C programs. But code generated by > FPC only has __bss_start.) Without seeing your code it is impossible to comment with any authority. It sounds like you're making things overly compilcated though. If it works in C without this information then you probably don't need it. Otherwise, you could try writing a small routine to return the correct information to Pascal and add it to the library.

I've attached the code for the unit and a small test program. The unit works on Win32 with the gc compiled as a DLL. However it does'nt work when used with the libgc.so shared library on linux. Is this a FPC-shared lib issue ?

Does FPC generate proper PIC code ?

Hope that helps,

Yes that did help. thanks.

cheers,
-Krish

Unknown author
Does FPC generate proper PIC code ?

IIRC, no it doesn't. Others may have better info - indeed it may now generate PIC properly, but I seem to remember this was an issue at one point and I don't remember anyone announcing that it had been fixed.

Matt

---------------------------------------------
This message was sent using Mistral WebMail.
http://www.mistral.co.uk/

Peter Vreman
to Unknown author
Show quoted text 7 lines
> Does FPC generate proper PIC code ? IIRC, no it doesn't. Others may have better info - indeed it may now generate PIC properly, but I seem to remember this was an issue at one point and I don't remember anyone announcing that it had been fixed.

It does not generate PIC code. For PIC code to be generated the compiler needs a new register allocator, because you need an extra register to hold the GOT

Marco van de Voort
to V.Krishnakumar: I've attached the code for the unit and a small test program. The unit works on Win32…
Show quoted text 8 lines
> C without this information then you probably don't need it. Otherwise, you > could try writing a small routine to return the correct information to > Pascal and add it to the library. > I've attached the code for the unit and a small test program. The unit works on Win32 with the gc compiled as a DLL. However it does'nt work when used with the libgc.so shared library on linux. Is this a FPC-shared lib issue ?

Probably not.

Does FPC generate proper PIC code ?

No, but it should matter for something like this.

It only matters in cases where you compiler/create your FPC program, and then start messing with libgc.so. (e.g. upgrade it, move the binary to a different distribution etc)