[fpc-pascal] Inline ASM code

2017-08-23 Thread LacaK
Hi *, I need store result of floating point calculation (in my example arctan()) in memory pointed by some variable. See this code: var a: single; pa: PSingle; asm fild dy fild dx fpatan fstp a fwait end; pa^ := a; It works, but is there any way how to store

Re: [fpc-pascal] Freepascal Floating Point Issue

2017-08-23 Thread Ralf Quint
On 8/22/2017 5:16 PM, Paul Nance wrote: > Turbo Pascal also had a BCD unit. Well, no, there was no unit, rather a version of Turbo Pascal 3.0x had a version that natively used BCD math for "reals" instead of the 6byte REAL type, just as there was a x87 version that used hardware x87 FP (IEEE754) fl

Re: [fpc-pascal] Freepascal Floating Point Issue

2017-08-23 Thread Ralf Quint
On 8/23/2017 5:11 AM, Benito van der Zander wrote: >> Btw, anyone know about a BCD math implementation for Free Pascal, like >> it used to be implemented in DR CBASIC? (those were the days... ;-) ) > > > I have one here: http://benibela.de/sources_en.html#bigdecimalmath Thanks, but that is not quit

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
On 23.08.2017 20:38, Marcos Douglas B. Santos wrote: > On Wed, Aug 23, 2017 at 3:25 PM, Sven Barth via fpc-pascal > wrote: >> On 23.08.2017 19:57, Marcos Douglas B. Santos wrote: >>> Would we have any problem of memory leaks using Interface helper with >>> COM interfaces (refcount)? >>> I mean, th

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 3:25 PM, Sven Barth via fpc-pascal wrote: > On 23.08.2017 19:57, Marcos Douglas B. Santos wrote: >> Would we have any problem of memory leaks using Interface helper with >> COM interfaces (refcount)? >> I mean, the "type helper" has constructor/destructor to create/release

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
On 23.08.2017 19:57, Marcos Douglas B. Santos wrote: > On Wed, Aug 23, 2017 at 2:45 PM, Sven Barth via fpc-pascal > wrote: >> Am 23.08.2017 19:39 schrieb "Marcos Douglas B. Santos" : >>> >>> Wait a minute. Now I realize that procedure IShellLinkHelper.Save is a >>> real implementation not by a cla

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 2:45 PM, Sven Barth via fpc-pascal wrote: > Am 23.08.2017 19:39 schrieb "Marcos Douglas B. Santos" : >> >> Wait a minute. Now I realize that procedure IShellLinkHelper.Save is a >> real implementation not by a class, but by a "interface helper". >> It's like default methods

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 16:01 schrieb "Anthony Walter" : > > As to what they are useful for, consider the following: > > type > // IShellLink is define by Microsoft > IShellLinkHelper = record helper for IShellLink > public > procedure Save(const Target, Description, Link: string); > end; > > pro

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 19:40 schrieb "Anthony Walter" : > > Sven, multiple helpers would be greatly appreciated, especially considering everyone wants to add their own helpers for types like string. At least in FPC modes they can use inheritance to solve this (see below) or by putting their units after the

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 19:39 schrieb "Marcos Douglas B. Santos" : > > On Wed, Aug 23, 2017 at 11:00 AM, Anthony Walter wrote: > > Marco, it doesn't work that way. > > > > Type helpers simply allow you to extend an existing type with new methods > > and/or properties. When you declare a type helper you exte

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Anthony Walter
Sven, multiple helpers would be greatly appreciated, especially considering everyone wants to add their own helpers for types like string. Thanks again! ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailm

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 11:00 AM, Anthony Walter wrote: > Marco, it doesn't work that way. > > Type helpers simply allow you to extend an existing type with new methods > and/or properties. When you declare a type helper you extend all instances > of said type given that: > > A) You 'use' the unit

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 12:13 PM, Sven Barth via fpc-pascal wrote: > Am 23.08.2017 16:58 schrieb "Marcos Douglas B. Santos" : >> >> Is this compatible with Delphi? > > Interface helpers are only supported by FPC. But the other helpers (class, > record, primitive types) are Delphi compatible. Alri

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 16:01 schrieb "Anthony Walter" : > > Marco, it doesn't work that way. > > Type helpers simply allow you to extend an existing type with new methods and/or properties. When you declare a type helper you extend all instances of said type given that: > > A) You 'use' the unit declaring t

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 16:59 schrieb "Marcos Douglas B. Santos" : > > On Wed, Aug 23, 2017 at 11:07 AM, Anthony Walter wrote: > > Here is another example: > > > > type > > TDay = (Monday = 0, Tuesday, Wednesday, Thursday, Friday, Saturday, > > Sunday); > > > > TDayHelper = record helper for TDay > >

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 16:58 schrieb "Marcos Douglas B. Santos" : > > On Wed, Aug 23, 2017 at 11:00 AM, Anthony Walter wrote: > > Marcos, it doesn't work that way. > > > > Type helpers simply allow you to extend an existing type with new methods > > and/or properties. When you declare a type helper you ext

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 11:07 AM, Anthony Walter wrote: > Here is another example: > > type > TDay = (Monday = 0, Tuesday, Wednesday, Thursday, Friday, Saturday, > Sunday); > > TDayHelper = record helper for TDay > function AsByte: Byte; > function ToString: string; > end; I didn't

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 11:00 AM, Anthony Walter wrote: > Marcos, it doesn't work that way. > > Type helpers simply allow you to extend an existing type with new methods > and/or properties. When you declare a type helper you extend all instances > of said type given that: > > A) You 'use' the uni

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Anthony Walter
Here is another example: type TDay = (Monday = 0, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); TDayHelper = record helper for TDay function AsByte: Byte; function ToString: string; end; function TDayHelper.AsByte: Byte; begin Result := Ord(Self); end; function TDayHe

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Anthony Walter
Marco, it doesn't work that way. Type helpers simply allow you to extend an existing type with new methods and/or properties. When you declare a type helper you extend all instances of said type given that: A) You 'use' the unit declaring the type helper in some other unit. B) No other unit you'r

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-23 Thread Dmitry Boyarintsev
On Wed, Aug 23, 2017 at 3:50 AM, Florian Klämpfl wrote: > Am 22.08.2017 um 15:59 schrieb Martok: > > As a heads-up: whatever tool you end up using, make sure you do NOT > translate > > the C enums in mpfr.h as enumerations. It will work, but create > unpredictable > > codegen on the FPC side. > >

Re: [fpc-pascal] StringOfChar for Unicode/Widestring

2017-08-23 Thread Bart
On 8/21/17, Bart wrote: > (which may tell you more about me that fpc). OK, that makes no sense... I meant to say: (which may say more about me,than it may say about fpc) Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.fr

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Marcos Douglas B. Santos
On Wed, Aug 23, 2017 at 6:18 AM, Sven Barth via fpc-pascal wrote: > Am 23.08.2017 09:42 schrieb "Michael Van Canneyt" : >> >> >> Any other examples ? > > It's the same as for the other kinds of helpers: being syntactic sugar. > E.g. if I have an interface that has two methods that both return a st

Re: [fpc-pascal] Freepascal Floating Point Issue

2017-08-23 Thread Benito van der Zander
Btw, anyone know about a BCD math implementation for Free Pascal, like it used to be implemented in DR CBASIC? (those were the days... ;-) ) I have one here: http://benibela.de/sources_en.html#bigdecimalmath Am 23.08.2017 um 02:16 schrieb Paul Nance: Turbo Pascal also had a BCD unit. On Au

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Sven Barth via fpc-pascal
Am 23.08.2017 09:42 schrieb "Michael Van Canneyt" : > > > > On Tue, 22 Aug 2017, Anthony Walter wrote: > >> I just wanted to point out that revision 37023 Sven added type helper >> support for interfaces. >> >> Good job and thank you Sven! >> > > I'm having trouble understanding why this could be u

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-23 Thread Florian Klämpfl
Am 22.08.2017 um 15:59 schrieb Martok: > If your header looks enough like IDL (which is essentially C++ with > annotations), you may also be able to use one of the available IDL compilers. > There are a few dialect issues though, so YMMV. I'd say MPFR has a few defines > too many for my idlproc (ht

Re: [fpc-pascal] Check In Interface Type Helpers

2017-08-23 Thread Michael Van Canneyt
On Tue, 22 Aug 2017, Anthony Walter wrote: I just wanted to point out that revision 37023 Sven added type helper support for interfaces. Good job and thank you Sven! I'm having trouble understanding why this could be useful (apart from completeness). The only thing I can come up with is a

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-23 Thread Martok
If your header looks enough like IDL (which is essentially C++ with annotations), you may also be able to use one of the available IDL compilers. There are a few dialect issues though, so YMMV. I'd say MPFR has a few defines too many for my idlproc (https://github.com/martok/idlproc), but may come

Re: [fpc-pascal] H2pas tool vs others, C header translation

2017-08-23 Thread LacaK
I'm using Chelper. (http://wiki.freepascal.org/Chelper) It's my choice, because it preserves comments (which is usually an important part of open-source libs) plus, can be configured to handle library header-specific defines. Naturally, the process is semi-automatic, but get be done quite quick