Sign in Join

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

Mailing lists / lazarus / 2003-12

fpc 1.9: global property

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Vincent Snijders

Hi,

fpc 1.9 support global properties, see for example rtl/linux/baseunix.pp.

The codetools don't support them and give an error: Error expected end., but property found.

Regards,
Vincent.

Reply by email

Mattias Gaertner
to Unknown author: They are the same as normal properties, only without class. Read/write specifiers can be…
Show quoted text 51 lines
> > > Interesting feature. > > > Where can I find the specs? > > > >They are the same as normal properties, only without class. Read/write > >specifiers can be in another unit, and properties can be grouped as in > >var/const/type/resourcestring blocks. > > > >So something like: > > > >Unit SomeProps; > > > >Uses > > ReadWriteUnit; > > > >Property > > A1 : Integer Read GetA1 Write SetA1; > > A2 : Integer Read GetA2 Write SetA2; > > Cool :-) The main idea is to keep code that depends on variables in an external lib that are exported via function into variable notation. E.g. libc's errno (the problem in question) is exported by libc as a function that returns a pointer to the (right threadinstance of ) errno. Libc hides this with a macro. So function __error():pcint; external name '__errno'; // FreeBSD libc, Linux calls it errno_location procedure seterrno(newerrno:cint); begin __error():=i; end; function geterrno:cint; begin result:=__error(); end; property errno : cint read geterrno write seterrno; begin errno:=5; // behaves like when accessed in C, but threadsafe. writeln(errno); end;

:)

The codetools support it now.

Mattias

Reply by email

Marco van de Voort
to Unknown author: They are the same as normal properties, only without class. Read/write specifiers can be…
Show quoted text 19 lines
> > Interesting feature. > > Where can I find the specs? > >They are the same as normal properties, only without class. Read/write >specifiers can be in another unit, and properties can be grouped as in >var/const/type/resourcestring blocks. > >So something like: > >Unit SomeProps; > >Uses > ReadWriteUnit; > >Property > A1 : Integer Read GetA1 Write SetA1; > A2 : Integer Read GetA2 Write SetA2; Cool :-)

The main idea is to keep code that depends on variables in an external lib that are exported via function into variable notation.

E.g. libc's errno (the problem in question) is exported by libc as a function that returns a pointer to the (right threadinstance of ) errno. Libc hides this with a macro.

So

function __error():pcint; external name '__errno';  // FreeBSD libc,
Linux calls it errno_location
procedure seterrno(newerrno:cint);
begin
  __error():=i;
end;
function geterrno:cint;
begin
  result:=__error();
end;
property
   errno : cint read geterrno write seterrno;
begin
  errno:=5;		// behaves like when accessed in C, but threadsafe.
  writeln(errno);
end;

Reply by email

Mattias Gaertner
to Vincent Snijders: fpc 1.9 support global properties, see for example rtl/linux/baseunix.pp. The codetools…
Show quoted text 10 lines
On Fri, 26 Dec 2003 17:28:24 +0100 Vincent Snijders wrote: > Hi, > > fpc 1.9 support global properties, see for example > rtl/linux/baseunix.pp. > > The codetools don't support them and give an error: > Error expected end., but property found.

Implemented.

Interesting feature. Where can I find the specs?

Question is still open.

Mattias

Reply by email

Marc Weustink
to Vincent Snijders: fpc 1.9 support global properties, see for example rtl/linux/baseunix.pp. The codetools…
Show quoted text 30 lines
On Fri, 26 Dec 2003, Mattias Gaertner wrote: > On Fri, 26 Dec 2003 17:28:24 +0100 Vincent Snijders > wrote: > > > Hi, > > > > fpc 1.9 support global properties, see for example > > rtl/linux/baseunix.pp. > > > > The codetools don't support them and give an error: > > Error expected end., but property found. > > Interesting feature. > Where can I find the specs? They are the same as normal properties, only without class. Read/write specifiers can be in another unit, and properties can be grouped as in var/const/type/resourcestring blocks. So something like: Unit SomeProps; Uses ReadWriteUnit; Property A1 : Integer Read GetA1 Write SetA1; A2 : Integer Read GetA2 Write SetA2;

Cool :-)

Marc

Reply by email

Mattias Gaertner
to Vincent Snijders: fpc 1.9 support global properties, see for example rtl/linux/baseunix.pp. The codetools…
Show quoted text 32 lines
On Fri, 26 Dec 2003, Mattias Gaertner wrote: > On Fri, 26 Dec 2003 17:28:24 +0100 Vincent Snijders > wrote: > > > Hi, > > > > fpc 1.9 support global properties, see for example > > rtl/linux/baseunix.pp. > > > > The codetools don't support them and give an error: > > Error expected end., but property found. > > Interesting feature. > Where can I find the specs? They are the same as normal properties, only without class. Read/write specifiers can be in another unit, and properties can be grouped as in var/const/type/resourcestring blocks. So something like: Unit SomeProps; Uses ReadWriteUnit; Property A1 : Integer Read GetA1 Write SetA1; A2 : Integer Read GetA2 Write SetA2;

Thanks. That needs some more work ...

Mattias

Reply by email

Unknown author
to Vincent Snijders: fpc 1.9 support global properties, see for example rtl/linux/baseunix.pp. The codetools…
Mattias Gaertner wrote 13 lines
On Fri, 26 Dec 2003 17:28:24 +0100 Vincent Snijders wrote: > Hi, > > fpc 1.9 support global properties, see for example > rtl/linux/baseunix.pp. > > The codetools don't support them and give an error: > Error expected end., but property found. Interesting feature. Where can I find the specs?

They are the same as normal properties, only without class. Read/write specifiers can be in another unit, and properties can be grouped as in var/const/type/resourcestring blocks.

So something like:

Unit SomeProps;
Uses
  ReadWriteUnit;
Property
  A1 : Integer Read GetA1 Write SetA1;
  A2 : Integer Read GetA2 Write SetA2;

Michael.

Reply by email