Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN

2022-01-05 Thread Dmitry Boyarintsev via fpc-pascal
On Wed, Jan 5, 2022 at 5:05 AM Michael Van Canneyt via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> I have made some changes, hopefully all is fixed..
>
The redirect has been added.

Can the search form also be changed to use "https://; instead of "http://;
as its action?

Currently it is:
http://forum.lazarus.freepascal.org/index.php?action=search;
method="get">
   
   

   
  

thanks,
Dmtry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN

2022-01-05 Thread Dmitry Boyarintsev via fpc-pascal
On Wed, Jan 5, 2022 at 2:49 AM Dimitrios Chr. Ioannidis via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> the certificate issued for www.freepascal.org and not for freepascal.org .
>
> It seems that the let's encrypt script was run with -d freepascal.org
> instead of -d *.freepascal.org .
>

I don't know how it works for Open Source world, but for the commercial
world wild-card certificates (*.freepascal.org) are more expensive, than a
single name certificate (www.freepascal.org)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] freepascal.org SSL_ERROR_BAD_CERT_DOMAIN

2022-01-04 Thread Dmitry Boyarintsev via fpc-pascal
You probably want to give a bit more context here.

1. The error seems to be visible only in Safari (iOS or macOS).
I did test Chrome, it fails to open "https://freepascal.org; and
automagically reopens "www.freepascal.org". Thus the certificate error is
not observed.
Chrome also suggested that request to "https://freepascal.org; fai
(The similar behavior is seen on Edge, which is Chrome anyway)

2. I'd think it would be proper for the server of "freepascal.org" to
response with a redirect to "www.freeepascal.org"

3. Even "www.freepascal.org" has a problem. The browser doesn't seem to
like that the "search" form action is leading to insecure "
http://forum.lazarus.freepascal.org/index.php?action=search; and thus a
warning sign is shown
[image: image.png]

thanks,
Dmitry

On Tue, Jan 4, 2022 at 7:00 PM Rainer Stratmann via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> https://freepascal.org/
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Explicit Interface implementation and inheritance

2021-08-14 Thread Dmitry Boyarintsev via fpc-pascal
Hello,

Why is interface implementation not inherited, if explicit implementation
is used.

Example.

Here are interfaces:
  IAAA = interface
procedure MethodA;
  end;
  IBBB = interface(IAAA)
procedure MethodB;
  end;

Interface IBBB inherits from IAAA

Here's an implicit interface implementation:

  TObjA = class(TInterfacedObject, IAAA)
procedure MethodA;
  end;

  TObjB = class(TObjA, IBBB)
procedure MethodB;
  end;

Class TObjB inherits from TObjA. Where TObjA implements IAAA.
And so TObjB only needs to implement MethodB, and MethodA is implicitly
mapped for the interface method.

Here's an explicit interface implementation:

  TImpA = class(TInterfacedObject, IAAA)
  public
procedure CallOfA; virtual;
procedure IAAA.MethodA = CAllOfA;
  end;

  // compiler error. No matching implementation for interface method
"MethodA"; found
  TImpB = class(TImpA, IBBB)
  public
procedure CallOfB;
procedure IBBB.MethodB = CallOfB;
  end;

Why is it happening? TImpB inherites from TImpA. In TImpA the MethodA is
implemented by "CallOfA".

Is it a requirement to map all the methods of implemented interfaces? (no
matter if they were implemented in parent classes).

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-12 Thread Dmitry Boyarintsev via fpc-pascal
On Thu, Aug 12, 2021 at 2:00 AM Bo Berglund via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

>
> What could I replace these svn co (or svn export) calls with?
>
the current:
svn co https://svn.freepascal.org/svn/fpc/tags/$FPCTAG/ $FPCVER
turns into:
svn co https://github.com/fpc/FPCSource/tags/$FPCTAG/$FPCVER

If you open https://github.com/fpc/ you can find all the mirrors are there.
And this is the official Github mirror, so all the latest changes should be
reflected there pretty quickly.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-12 Thread Dmitry Boyarintsev via fpc-pascal
On Thu, Aug 12, 2021 at 1:34 AM LacaK via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> I have related question: in SVN was possible to checkout specific
> sub-directory (for example if I am interested in fcl-db package only I
> checkedout only this sub-directory).
> Is it possible with gitlab? Or I must clone whole
> https://gitlab.com/freepascal.org/fpc/source ?
>

No. This is not possible with Git.
You either have to deal with the entire project structure or you could use
an SVN mirror (i.e. github based)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-11 Thread Dmitry Boyarintsev via fpc-pascal
On Thu, Aug 12, 2021 at 12:27 AM Michael Van Canneyt via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> It's like switching car brands from a VW to an Audi or so.
> Some buttons are in different places, your key will maybe look different,
> but that's it. It's a car, it brings you from a to b.
>
It's not switching brands, it's switching the type of the car.
from a passenger i.e. to a bus.
It's still a car, but the concept is a little different.


> A file version system manages versions of files.
> The actual commands differ a little, but that's it.
>

The human psychology. There were no particular problems for anyone to use
SVN.
It worked fine. So for the people it doesn't seem like an obvious reason
for the change.
The change is not recognized by the brain as a needed change, as a cure of
some sort.
Instead it's recognized as an unnecessary burden.
(unlike switching from CVS to SVN)

The same is happening with kids at school. They don't recognize the new
knowledge as something useful.
Instead they still treat the school as a burden.
---
In the software we for some reason prefer to stick to "backwards
compatibility"
No matter how much it affects a project. (it's considered that retaining
backwards compatibility is a positive effect).
However the same concept doesn't apply to the infrastructure for some
reason.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-11 Thread Dmitry Boyarintsev via fpc-pascal
On Wed, Aug 11, 2021 at 5:37 PM Michael Van Canneyt via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> > why not to use Github mirror?
> Why not encourage people to go with the times ?
>
it might depend on the use of the version control.
Maybe there's a certain automation involved behind the scenes.
If it used to be configured for SVN then the only allowed kind of change is
the URL address.


> As a programmer, switching version systems should be a no-brainer.
>
amen

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to get fpc and lazarus sources when svn has shut down?

2021-08-11 Thread Dmitry Boyarintsev via fpc-pascal
why not to use Github mirror?

svn co https://github.com/fpc/FPCSource/trunk
or
svn co https://github.com/fpc/FPCSource/tags/$FPCTAG/



thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Defender considers fp.exe a malicious program

2021-02-12 Thread Dmitry Boyarintsev via fpc-pascal
Are signed executables subject to anti-virus inspection?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] bug tracker (bugs.freepascal.org) APPLICATION ERROR #400 (db connection failed)

2020-08-30 Thread Dmitry Boyarintsev via fpc-pascal
The site opens up with:

APPLICATION ERROR #400

Database connection failed. Error received from database was #-1: Database
connection failed.

Please use the "Back" button in your web browser to return to the previous
page. There you can correct whatever problems were identified in this error
or select another action. You can also click an option from the menu bar to
go directly to a new section.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Add API to official documentation search

2019-11-17 Thread Dmitry Boyarintsev via fpc-pascal
On Sunday, November 17, 2019, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:
>
> Either way, that's a pie in the face for Embarcadero. :-)
>

They probably asked Embarcadero the same question for Delphi language
reference

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String type with specified length and without codepage

2019-08-18 Thread Dmitry Boyarintsev
RawByteString?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Initial support for Custom Attributes

2019-07-13 Thread Dmitry Boyarintsev
On Fri, Jul 12, 2019 at 6:10 PM Sven Barth via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> The wiki pages New Features Trunk and User Changes Trunk will be updated
> soon with the new information.
>

Here's a stand-alone page too
https://wiki.freepascal.org/Custom_Attributes
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] specify variable name with string variable

2019-07-07 Thread Dmitry Boyarintsev
associative array?

On Sunday, July 7, 2019, James Richters 
wrote:

> This might sound silly,  but is it possible to somehow specify a variable
> with a string containing the name of the variable?
>
> For example:
>
> Var
>MyVariable1 : Word;
>MyVariableName : String;
>
> Procedure ShowVariable(Variablename);
> Begin
> Writeln(Variablename,' = $', inttohex((Somehow get the value of the
> variable specified by the name here ) ,4));
> End;
>
> Begin
> MyVariableName:= 'MyVariable1';
> ShowVariable(MyVariableName);
> End.
>
> Is such a thing possible?
>
> James
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] wiki.freepascal.org is down?

2019-06-05 Thread Dmitry Boyarintsev
It's in maintenance mode now.
You can actually open a sub page.
I.e.: http://wiki.freepascal.org/Lazarus_Faq

Yet the main page seems to be affected.

On Wed, Jun 5, 2019 at 9:42 AM denisgolovan  wrote:

> Hi
>
> I get empty pages when browsing http://wiki.freepascal.org/
> Is it some bug or I am doing something wrong?
>
> --
> Regards,
> Denis Golovan
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Adding options when building packages

2018-11-27 Thread Dmitry Boyarintsev
On Tue, Nov 27, 2018 at 9:55 AM Ryan Joseph 
wrote:

>
> Is there is a way I can add
> "-Fl/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib” to that
> command so it finds the file?
>
> make 
OPT='-Fl/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
...extra options...'
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] odd compiling + linking error (with invalid casting of Exp)

2018-10-29 Thread Dmitry Boyarintsev
I'm using 3.0.4 (win32), could any one try it on a later version of the
compiler?

The code i'm compiling looks like this:
--
{$mode delphi}

type
  Ttest = class(TObject)
  public
Value: string;
  end;

function Custom: extended;
begin
  Result := 0;
end;

begin
  // writeln( TTest(Custom).Value );
  writeln( TTest(Exp).value);
end.
--
It gives the linking error:
sample.pas(17,1) Error: Undefined symbol:
SYSTEM_::=::\_EXP$EXTENDED::=::\EXTENDED
sample.pas(17,1) Fatal: There were 1 errors compiling module, stopping

If one un-comments  the line with invalid Custom() cast, they would get a
compiling error instead:
Compiling sample.pas
sample.pas(15,12) Error: Illegal type conversion: "Extended" to "Ttest"
(which is expected).

Is the issue known? worth bug reporting?
(clearly a compiler error should be thrown, rather than a linker error)

The issue I actually ran into is with a bigger project:
Error: Undefined symbol: SYSTEM_::=::\_EXP$EXTENDED::=::\EXTENDED
doesn't indicate the source code or line numbers.
So catching the problem might be tricky.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] FPC for linking only

2018-08-20 Thread Dmitry Boyarintsev
Hello,

Is it possible to use FPC for linking only?
(assuming that .ppu/.o files were created by fpc previously)

using options
-shGenerate script to link on host
or
-stGenerate script to link on target
generates the linking script, but the script is referring to an external
linker.

Is there possibility to do use internal linker/writer only?

The reasons for that:
* reduce dependencies on external build tools;
* on some platforms (win32) the internal linker is presumed to be better
than external one;

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Assigning open array

2018-07-31 Thread Dmitry Boyarintsev
On Tue, Jul 31, 2018 at 11:39 AM Santiago A.  wrote:

> I'm not very sure how open arrays are copied
>
In your example you don't have open arrays used - you have dynamic arrays.


> I looks like working fine.  MyArray.ArrayInt[0] is still 5. But I wonder
> whether it is really right or just luck. Open arrays are pointers, so,
> when tmpList gets out of scope then tmpList.arrayInt is freed.


The compiler is aware of managed (reference counted) type fields within a
dynamic array body.
Thus each ArrayInt in "aList" would have reference count increased.
Thus when tmpList is released ArrayInt stays, as its reference count
doesn't reach zero.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] access violation?

2018-07-27 Thread Dmitry Boyarintsev
On Fri, Jul 27, 2018 at 3:22 PM, Michael Van Canneyt  wrote:

> In order to have robust, maintainable and portable (to either other
>> platform or even language) a developer should respect high-level rules and
>> never depend on low-level rules to be the same on any platform.
>>
>
> Do I have permission to quote you the next time someone starts about how
> the lifetimes of interfaces are managed slightly differently in FPC and
> Delphi ?
>
> :)


Permission granted.
I thought all (COM) interfaces have been resolved, back in 2.6?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] access violation?

2018-07-27 Thread Dmitry Boyarintsev
On Fri, Jul 27, 2018 at 1:06 PM, Ryan Joseph 
wrote:

> I had no idea you could do that!
>

Obviously, it speaks high of your abilities ;)
You've been able to accomplish your tasks without use of hacks (of any
kind), playing strict by the rules.


I’m totally confused now. Since when was it ok to call methods on nil
> objects? According to this test not only can you call methods on nil
> objects but it calls the method statically (like a class method), i.e the
> test prints “DoThis”. How is that possible?
>

>From the low-level (virtual/physical memory, CPU) perspective you can do
that at any time on either nil-ed or uninitialized object as long as the
method doesn't try to access and invalid memory.

The example (compiled for i386 and not using -CR works as expected)

type
  TRobust = class(TObject)
  public
v : Integer;
function Max(a,b: Integer): Integer;
  end;

function TRobust.Max(a,b: Integer): Integer;
begin
  if a>b then Result:=a
  else Result:=b;
end;

var
  r : TRobust;
begin
  r := nil;
  writeln(r.Max(5,10));
end.

However such behavior, would be RTL specific - it's all about how the
compiler would generate such call. If it would attempt to access any field
(i.e. VMT) related to the instance of the object itself (rather than the
class), there's a high chance it would fail.

And that's why having -CR enabled during development is generally a very
good idea.

>From high-level (OOP) such actions are not welcomed (and are enforced using
-CR in case of FPC).

In order to have robust, maintainable and portable (to either other
platform or even language) a developer should respect high-level rules and
never depend on low-level rules to be the same on any platform.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] access violation?

2018-07-27 Thread Dmitry Boyarintsev
On Fri, Jul 27, 2018 at 11:15 AM, Ryan Joseph 
wrote:

> I never use Free directly so I had no idea. How is that even accomplished
> in the language? I thought it was just a method and behaved accordingly.
>
> If it is magic then how do we call other methods on nil objects? There are
> times that would be handy if I could control it.


It's not a magic, it's explicit check for the value of "Self" within a
method.
Self would point to an actual instance of an object, if it's nil. Free
method won't do anything.

type
  TRobust = class(TObject)
  public
v : Integer;
procedure RobustMethod;
  end;

procedure TRobust.RobustMethod;
begin
  if Self = nil then Exit; // remove or comment out this line to start
getting AVs
  v := 5;
end;

var
  r : TRobust;
begin
  r := nil;
  r.RobustMethod;
end.

You could consider this a sanity check, similar to checking any other input
parameters.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] A new fpc desirable feature

2018-07-17 Thread Dmitry Boyarintsev
Please, fpc-other please
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] LongBool True = -1

2018-05-19 Thread Dmitry Boyarintsev
On Thu, May 17, 2018 at 5:26 PM, Anthony Walter  wrote:

> I am working with some a glib library that expects gboolean to be positive
> 1 for true, yet FPC emits -1 for true.
>

I'd think that pascal defines true as
  true = not false;
In case of unsigned integers "-1" is not an option

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC on gaming consoles: XBox One, PlayStation 4, Nintendo Switch

2018-05-09 Thread Dmitry Boyarintsev
On Wed, May 9, 2018 at 9:38 PM, Michalis Kamburelis <
michalis.ka...@gmail.com> wrote:

> This would mean that it is impossible to openly distribute an open-source
> code interfacing with e.g. PlayStation custom OS. Precluding open-source
> support from both FPC and Castle Game Engine for the consoles. Any code
> that uses some API covered by NDA must be closed-source, can be available
> only to people who also signed the NDA.
>

Not sure how much of impact it is for a game engine and/or FPC as is.
Unity engine is capable of compiling for PS4. Yet it's distributed freely.

Sure, it's a closed-source, but it doesn't mean that an open-source project
couldn't support the closed-source system.
It just requires some company with the business interest in it.

The first step to be done is to have a big game product at the market,
compiled with FPC.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Range checks

2018-01-27 Thread Dmitry Boyarintsev
On Sat, Jan 27, 2018 at 12:51 PM, Dmitry Boyarintsev <
skalogryz.li...@gmail.com> wrote:

>
> imho, bad approach to adjust compiler for not safe code.
> However, getting a compiler warning would be nice.
>
> Some time ago, the compiler has been extended with for-in syntax:
>
> var
>   SubView : NSView;
> begin
>   for SubView in ns.subviews do
>

That requires objectivec2 though
https://www.freepascal.org/docs-html/ref/refse76.html#x138-1611.10
(min version is macOS 10.5)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Range checks

2018-01-27 Thread Dmitry Boyarintsev
On Sat, Jan 27, 2018 at 12:30 PM, C Western  wrote:
>
> The actual code that triggered my interest was:
>
> procedure LCLViewExtension.lclSetEnabled(AEnabled: Boolean);
> var
>   ns : NSArray;
>   i  : integer;
>   obj : NSObject;
> begin
>   ns := subviews;
>   for i := 0 to ns.count - 1 do
>   begin
> obj := NSObject(ns.objectAtIndex( i ));
> ... process obj ...
>   end;
> end;
>
>
> Given how common the above bit of code is likely to be, I can't see any
> way of fixing this without some work in the compiler.


imho, bad approach to adjust compiler for not safe code.
However, getting a compiler warning would be nice.

Some time ago, the compiler has been extended with for-in syntax:

var
  SubView : NSView;
begin
  for SubView in ns.subviews do
  begin
.. process obj ...
  end

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Range checks

2018-01-27 Thread Dmitry Boyarintsev
On Sat, Jan 27, 2018 at 9:10 AM, C Western  wrote:

>
> I can (more or less) see why, but it means that I can't (for example)
> compile the Cocoa widget set in 64 bit with bounds checking on, as then
> qword seems to be used as a count for, for example, NSarray.
>
> how about taking objc approach:

 RangeCheckCount = objccategory(NSArray)
function intcount: Integer; message 'intcount';
  end;

{ RangeCheckCount }

function RangeCheckCount.intcount: Integer;
begin
  Result:=Integer(count);
end;

var
  arr : NSArray;

  for i:=0 to arr.intcount-1 do

?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Range checks

2018-01-27 Thread Dmitry Boyarintsev
On Sat, Jan 27, 2018 at 10:06 AM, Adriaan van Os  wrote:
>
>
> The code shouldn't generate a range check error, as the target type is
> signed.
>

Count returns Unsigned Qword.
unsigned $ is beyond 32-bit boundary.

The similar issue, but more explicit.

{$R+}
function Count: qword;
begin
  Result := 0;
end;

var
  i: Integer;
  K : Qword;
begin
  K:=count-1;
  writeln(K);
  I:=k;  // <-- rangecheck error
  writeln(i);
end.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Initializing constant (translate from C)

2017-10-16 Thread Dmitry Boyarintsev
On Mon, Oct 16, 2017 at 3:36 PM, Darius Blaszyk 
wrote:

> Here's an interesting one. In C I have this code:
>
> #define ID1 MAKE_ID('A', 'B')
>
> Where MAKE_ID is a macro that depending on the endianness of the target
> will create either AB or BA.
>
> The only issue with the following approach
const
  ID  ={$IFDEF ENDIAN_LITTLE} 'AB' {$ELSE} 'BA' {$ENDIF};

is if MAKE_ID is used anywhere else, you'll have to repeat the code.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2017-08-27 Thread Dmitry Boyarintsev
Is 2 neither true, nor false? 3? 4?

If false is zero,
Then true is not false.

Also C doesn't have a boolean type per se. Iirc it was introduced in some
version of c++ standard.

In C it's very strange to see code like that:

If (b==1)

It's always
If (b)
Or
If (!b)



On Sunday, August 27, 2017, <nore...@z505.com> wrote:

> On 2017-08-27 06:22, Dmitry Boyarintsev wrote:
>
>> On Sun, Aug 27, 2017 at 2:37 AM, <nore...@z505.com> wrote:
>>
>> Why borland chose the bool to not be 100 percent compatible, and
>>> only 50 percent compatible?
>>>
>>> Bool in delphi:
>>> true = -1
>>>
>>> Bool in C:
>>> true = ($)  1
>>>
>>> Why not just make it exactly compatible, there must be some
>>> underlying (possibly obnoxious) reason for this mess.
>>>
>>
>> They are compatible, if you declare like this:
>>
>> true = (not false);
>>
>>
> Depends, AFAIK, if the C library checks for an exact value of 1 somewhere,
> when Delphi/FPC sends in a -1, this could cause problems, but I haven't
> thought about it enough.
>
> I just don't see why both languages could not just agree to use "1", they
> must have had some reason, strange or not.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2017-08-27 Thread Dmitry Boyarintsev
On Sun, Aug 27, 2017 at 2:37 AM,  wrote:

>
> Why borland chose the bool to not be 100 percent compatible, and only 50
> percent compatible?
>
> Bool in delphi:
> true = -1
>
> Bool in C:
> true = ($)  1
>
> Why not just make it exactly compatible, there must be some underlying
> (possibly obnoxious) reason for this mess.


They are compatible, if you declare like this:
true = (not false);

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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.
>
> It is perfectly predictable. Just do not store invalid values in
> enumeration variables. And invalid
> is everything not being declared. This is how FPC works and will work.


Never saw FPC acting unpredictably.
(There was an issue back in the days with Delphi. But it's only because
delphi packs enumerations to 1 byte, where FPC packs them to 4 bytes in
objfpc mode)

Instead, I saw C-enumarations used as non-Pascal-enumerations. (which is
actually expected C<>Pascal).

For instance, it's common for C enumerations to be used used in bitwise
operations.
ENUM1 | ENUM2
(but report for sdl2 headers
https://github.com/ev1313/Pascal-SDL-2-Headers/issues/44)
not available in Pascal, unless an explicit type casting or sets are used.

So, in the end it's better to declare enumeration type elements as constant
and the type itself as an alias to integer (or cint)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2017-08-21 Thread Dmitry Boyarintsev
On Sun, Aug 20, 2017 at 5:37 PM,  wrote:

>
> Is there a competing tool that does more, or is updated more?
>

How about this list?
http://wiki.freepascal.org/C_to_Pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2017-08-21 Thread Dmitry Boyarintsev
On Sun, Aug 20, 2017 at 5:37 PM,  wrote:

> Is h2pas for example the one that is used for Mysql header translations
> and other major C headers?
>

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 quickly.


> I am looking to convert the GNU MPFR library header files, or hire someone
> on a bounty to do it if header translation is not so easy with h2pas and
> requires lots of hand work, and close checking.
>

Speaking of bounties.
There was a bounty (http://wiki.freepascal.org/Bounties#Linux_bounties) for
converting libwebsockets to fpc.
I took it and did the conversion using Chelper.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] C to Pascal conversion - Help request

2017-07-17 Thread Dmitry Boyarintsev
On Mon, Jul 17, 2017 at 7:17 AM, Sandro Cumerlato <
sandro.cumerl...@gmail.com> wrote:

> Hello,
> can someone please help me converting the folowing C types to Pascal?
>
SF_CUE_POINT is simple, but I'm not sure how to convert SF_CUES_VAR(count)
> ad SF_CUES.
>
>
type
   SF_CUES   = record
 cue_count : cuint32 ; // declared in "ctypes"
 cue_points : array [0..100-1] of SF_CUE_POINT;
   end;


going forward in C translation, any time you find SF_CUES_VAR (xxx) used,
you'll have to declare a new type (with the proper "count" used) or reuse
an existing type, if it already exists.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Food for thought - language string improvement

2017-07-10 Thread Dmitry Boyarintsev
On Mon, Jul 10, 2017 at 11:19 AM, Sven Barth via fpc-pascal <
fpc-pascal@lists.freepascal.org> wrote:

> Though you can't use the same code block for multiple types.
>
Structured development to the rescue :)

===
program project1;

{$mode delphi}
{$RANGECHECKS on}

uses SysUtils;

function HandlingIt(const e: exception): Integer;
begin
  writeln('something bad has happened:');
  writeln(e.message);
  Result:=0;
end;

function Catch(a,b: byte; oper: char): byte;
begin
  try
if oper = '+' then Result:=a+b
else if oper = '/' then Result:=a div b;
  except
on e: EDivByZero do begin
  writeln('division by zero');
  Result:=0;
end;
on e: EIntOverflow do Result:=HandlingIt(e);
on e: ERangeError do Result:=HandlingIt(e);
  end;
end;

begin
  writeln( catch (1,1,'+'));
  writeln( catch (255,255,'+'));
  writeln( catch (1,0,'/'));
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Food for thought - language string improvement

2017-07-10 Thread Dmitry Boyarintsev
On Mon, Jul 10, 2017 at 9:46 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2017-07-10 13:34, Dmitry Boyarintsev wrote:
>
>> are you referring to "Catching More Than One Type of Exception with One
>> Exception Handler" in
>> https://docs.oracle.com/javase/tutorial/essential/exceptions/catch.html
>>
>
> Yes. You can have multiple catch blocks inside the same try block.


Well, this has been in FPC/Delphi from the start
Ultimately handling multiple exceptions in one catch block is the whole
purpose of having exception mechanism in a language.


You can also have a single catch block with a comma separated list of
> exception types.
>

I think it's actually Pipe separated.
And is that true, that the variable specified for catching such exception
would default to a common "Exception" class?
Not available in freepascal indeed.



> Then lastly, you can even add a finally block in there too

Also not available, but people are asking :

https://bugs.freepascal.org/view.php?id=24216
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Food for thought - language string improvement

2017-07-06 Thread Dmitry Boyarintsev
On Thu, Jul 6, 2017 at 10:27 AM, Marcos Douglas B. Santos 
wrote:

> That would be very, very nice.
> And instead of using [ " ' sql ' " ] would be better to use just [ " sql "
> ].
>

The thread of discussion:
http://lists.freepascal.org/pipermail/fpc-devel/2016-February/036709.html
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] A jit tool for command line compilation of Pascal?

2017-02-05 Thread Dmitry Boyarintsev
InstantFPC ?

http://wiki.freepascal.org/InstantFPC

thanks,
Dmitry

On Sun, Feb 5, 2017 at 8:31 PM, Stuart Cox  wrote:

> Several years ago I seem to remember using a FPC tool that allowed me to
> write Pascal code and have its source file loaded, compiled and executed at
> the command line.  If I remember correctly, it kept access to the
> environment that it was being executed immediately under and so was like a
> Pascal .bat or .cmd.
>
> Can anyone refresh my memory, please?
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] ppcjvm issues

2017-01-27 Thread Dmitry Boyarintsev
On Fri, Jan 27, 2017 at 1:41 PM, Jonas Maebe  wrote:

>  It is defined as "if the instance is not nil, then it calls the destroy
> method, and next it calls FreeInstance". You could override FreeInstance to
> not free memory on any platform.
>
> However, if JVM free method would at least reset "o" reference to nil,
>> then the semantic of "o" being an invalid object remains.
>>
>
> There is no need to do this.
>
> It also suggests to the garbage collector that the memory could be
>> recycled earlier, that the variable leaves the scope.
>>
>
> That is true.


How about moving "nil"-ing of the reference into default FreeInstance for
JVM target?

The whole point of removing the reference, is to let the collector to
dispose of the object as soon as possible.

I'm thinking about classes that consume a lot of (system) resources and
release them only in during destruction.
Releasing them as soon as possible **might** be a benefit for the code
behavior over all.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] ppcjvm issues

2017-01-27 Thread Dmitry Boyarintsev
On Fri, Jan 27, 2017 at 12:52 PM, Jon Foster 
wrote:

> Correct me if I'm wrong: It would seem like that your free implementation
>> doesn't actually do anything, other than fulfilling the obligation of
>> having a "free". If I do this:
>>
>
> var
> o: TObject;
> begin
> o:=TObject.create;
> { do something ... }
> o.free;
> end.
>
> Wouldn't "o" still contain a reference after "free" is called? In non-JVM
> FPC "self" is just another variable, who's origin is somewhat hidden by the
> compiler. The call to "o.free" would do something like "TObject.free(o)"
> where "o" is passed by *value* into the procedure variable "self". "Self"
> comes and goes with the scope of the "TObject.free" procedure. Which is why
> if I'm concerned about detecting whether or not "o" still contains a
> correct object reference I would need to do something like this: "o.free;
> o:=nil;" so I can test for "nil" later. Although I think FPC added a
> procedure to do that some time back. Yup, I see it "SysUtils.FreeAndNil".
>
> I'm not sure of the specific semantics of the JVM calls but from what I
> read in the various FPC JVM related pages on the wiki it would seem to use
> similar semantics.


Object Pascal semantic of calling .Free suggests that "o" would no longer
be a valid object.
If a dummy Free method is available for JVM, then such semantic is violated.

However, if JVM free method would at least reset "o" reference to nil, then
the semantic of "o" being an invalid object remains.

It also suggests to the garbage collector that the memory could be recycled
earlier, that the variable leaves the scope.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] ppcjvm issues

2017-01-27 Thread Dmitry Boyarintsev
On Tue, Jan 10, 2017 at 6:14 AM, Michael Schnell  wrote:

>
> If destroying an object is not necessary, the class should provide a dummy
> Free procedure. So the application programmer always can/should use Free.
>
> Why dummy? if it should be like this

procedure TObject.Free;
begin
  if Self<>nil then Self:=nil;
end;

Destroying object is not necessary, but dereferencing is.
If the code keeps the reference to an object, it would not be collected.

For example. In pascal:
var
  b : TSomeClass;
begin
  b := TSomeClass.Create; // allocated
  ..
  b.Free;  // freed (b becomes an invalid pointer)
  ...
end.

JVM with dummy Free
var
  b : TSomeClass;
begin
  b := TSomeClass.Create; // allocated
  ..
  b.Free;  // does nothing (b remains a valid pointer)
  ...
end.// a might be freed after leaving  the scope of visibility

JVM with nil-ing Free.
var
  b : TSomeClass;
begin
  b := TSomeClass.Create; // allocated
  ..
  b.Free;  // derefering a, (a, become nil)

  ... // a might be Freed here somewhere, whenever gc occurs
end.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] alignment of types ( __alignof__ in fpc)

2017-01-11 Thread Dmitry Boyarintsev
Hello,

Porting some C-headers. Ran, into a declaration:

#define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *))

_alignof_ seems to be a compiler attribute
https://gcc.gnu.org/onlinedocs/gcc/Alignment.html

Is there anything similar available fpc?

Delphi doesn't seem to have any
http://stackoverflow.com/questions/30454118/how-to-translate-alignof-to-delphi

GNU Pascal seems to have.
http://www.gnu-pascal.de/gpc/AlignOf.html

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] C# translatation

2017-01-08 Thread Dmitry Boyarintsev
On Sun, Jan 8, 2017 at 12:22 PM, Sven Barth 
wrote:

> The closest equivalence to bitwise and in Pascal is bitwise and.
>
> The operators "and", "or", "xor" and "not" are logical or bitwise
> depending on their arguments.
>

With that said...



On Sun, Jan 8, 2017 at 11:46 AM, José Mejuto  wrote:

>
> Both work the same way but pascal does not have the assignment and testing
> mess that can be written in C like:
>
> C / C++:
>
> a = b && c;
>
> Pascal:
>
> a := (b<>0) and (c<>0);
>

There's another approach to resolved that.

The following code works as expected

{$mode objfpc}

var
  b,c : integer;
  a   : Boolean;
  ai  : integer;
begin
  b:=2;
  c:=3;
  ai:=b and c;
  a:=boolean(b) and boolean(c);
  writeln(a);
  writeln(ai);
  writeln(byte(a));
end.

output:
TRUE
2
1

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Dmitry Boyarintsev
On Sat, Jan 7, 2017 at 6:02 PM, Lars  wrote:

> Some brave soldiers once tried to reinvent generics using these tricks..


Well, Pascal run-time has been using "hidden" generics forever.

As an example:
http://www.freepascal.org/docs-html/rtl/system/val.html

Val() declares the second parameter as untyped var parameter.
Unfortunately, it's not quite so. Compiler recognizes  the run-time
function and requires the parameter to be either an Integer or Float-point
type (or an enumerated type since 2.3.1).

So it's more a generic-like behavior (with integer and float types
specialized)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Dmitry Boyarintsev
On Sat, Jan 7, 2017 at 6:53 PM, Bart  wrote:

> OK, I can imagine more complex examples where this may come in handy.
>
> And thanks for the rest of the explanation.


And only more complex examples should be used :)
There're much better ways to implement var-type variables.

I was always thinking that having untyped variables in Pascal is more a
syntactical advantage, whenever a Pascal need to target managed platforms
(i.e. Net or Java). These platforms don't any kind of pointers at all.
Thus a code written using pointers would not even compile on them.

Thus using open arrays (of bytes) and untyped variables would be a good
replacement for pointers whenever writing a cross-platform code (meaning a
code that would need to target both non-managed and managed platforms)

Not sure, but pascal JVM has its own means of dealing with pointers anyway.
My knowledge is poor on the subject of jvm, but it's well explained in the
wiki!

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Dmitry Boyarintsev
On Sat, Jan 7, 2017 at 5:42 PM, Bart  wrote:

>
> procedure X(var Y);
> begin
>   PInteger(Y)^ := 3;  //syntax may be wrong, too lazy to test
> end;
>
> To me this completely defies the purpose of an untyped var parameter,
> since in this exmaple you do know, @design time, the type of Y, so why
> not write then
>
> procedure X(var Y: Integer);
> begin
>   Y := 3;
> end;
>

Think about something like a var-type variable, where the actual type of Y
might vary.

procedure XX(var Y; YType: integer);
begin
  case YType  of
T_INT: PInteger(@Y)^:= 3;
T_SINGLE: PSingle(@Y)^:=3;
T_DOUBLE: PDouble(@Y)^:=3;
  end;
end;

Again, earlier in the thread I gave a link to anySort() example, that could
sort any array-like structure (as long as elements of the structure are
placed in sequential order in memory).

As I said mentioned earlier. Untyped parameter, is an implicit pointer
(since the value is always passed by reference).
But there's a compile-time difference.
If you'd declare a parameter as a pointer
procedure X( Y:Pointer);

Then it would be possible to use the function as following:
X(nil)
which requires you, at least add additional sanity check into X procedure.

But if you'd declare it as X(var Y), then the compiler would not allow to
pass nil, always requiring a user to provide a valid variable to be passed
and writing something like X(nil) is no longer possible.

Here's an example:
http://www.freepascal.org/docs-html/rtl/system/iunknown.queryinterface.html

QueryInterface must return an interface variable. BUT:
* the actual returned interface type is unknown at compile time.
* "obj" parameter must not be nil, since the reference must be written
somewhere.

It's also more convenient from syntax point of view, since a developer
doesn't have to write "@" symbol when passing a parameter. The reference
would be resolved by the compiler itself.


thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Dmitry Boyarintsev
On Sat, Jan 7, 2017 at 4:52 PM, Bart  wrote:

>
> But if you know that at forehand (and you know, since you cast it),
> why then use an untyped var parameter at all?
>

http://www.freepascal.org/docs-html/rtl/system/fillchar.html ?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-07 Thread Dmitry Boyarintsev
On Sat, Jan 7, 2017 at 2:37 PM, Andrew Hall  wrote:

> If you cast your “something” to a typed pointer, the compiler will do the
> work for you in the usual way:
>
> PDouble(something)^ := myDouble;
>
or rather
PDouble(@something)^ := myDouble;
?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-04 Thread Dmitry Boyarintsev
On Wed, Jan 4, 2017 at 10:24 AM, Ryan Joseph 
wrote:

> But how do you assign to “something" then if you don’t know the type? The
> param is “var” so shouldn’t I be able to assign to the param and return it
> back to the caller? In your example how could I return 5 to “i” inside
> GetSomething?
>
> Treat is as a pointer (it's an implicit pointer anyway)

function GetSomething (var something): boolean
var
  pi: PInteger;
begin
  pi:=@something;
  GetSomething:=pi^>=5;
end;

or an old-school way using "absolute".

function GetSomething (var something): boolean;
var
  i: Integer absolute something;
begin
  GetSomething:=i>=5;
end;

var
  i : integer;
begin
  i:=3;
  writeln(GetSomething(i));
end.

check out "anysort" function
http://wiki.freepascal.org/Array_sort

It's using untyped parameter to perform a sort on an arbitrary type array

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Untyped var params

2017-01-04 Thread Dmitry Boyarintsev
On Wed, Jan 4, 2017 at 9:29 AM, Ryan Joseph 
wrote:

> I’ve seen functions that use the untyped params like:
>
> function GetSomething (var something): boolean;
>
> This seems like something useful I would like to use but how can you
> assign to the parameter? I tried but I got an error message which is
> confusing because it’s a “var” after all.
>

A parameter you pass, would be passed by a reference (an address in memory)

Thus
  GetSomething(5)
will not work.


var
  i: integer;
begin
  i:=5;
  GetSometing(i)

Be careful using this open parameter, since you don't have any type
information about "something". You either should not assume the type or
pass the additional information

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] performance when resizing a dynamic array

2016-12-04 Thread Dmitry Boyarintsev
On Sun, Dec 4, 2016 at 5:28 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> If I use an array to hold a list of say Integers. Is there any serious
> performance penalty for resizing (growing) the dynamic array as I add
> items. My point being, I don't know the number of elements I'll need
> beforehand.
>

Power of 2 increments then (less re-allocations, less memory
fragmentation).
You'll also need to store the actual size somewhere next to the dynamic
array, since you can no longer rely on length()

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] SysSetCtrlBreakHandler

2016-11-30 Thread Dmitry Boyarintsev
On Tue, Nov 29, 2016 at 5:13 PM, Tomas Hajny  wrote:

>
> 1) Instead of using the special handler registered via
> SetConsoleCtrlHandler (invoked in a special thread), isn't it possible to
> process this event in the exception handler (running in the same thread
> probably)?
>

Not that I'm (or MSDN) aware of.
Instead there is a flag ENABLE_PROCESSED_INPUT that's on by default for a
console.
It would suppress the handler for Ctrl+C and would pass it as a regular key
combination (bringing the desired #3 keychar).

(as I noted in my comment in the bug tracker, clearing
ENABLE_PROCESSED_INPUT flag was used originally. See TurnMouseOff
procedure. However it was removed at some point, causing the regression?)

Windows is raising an exception only if a process is being debugged, so a
debugger would be aware of it. That's the only time, whenever the exception
is used. MSDN however doesn't specify at what thread the exception is
risen.

So the newest patch removes all threading-related concerns.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] SysSetCtrlBreakHandler

2016-11-27 Thread Dmitry Boyarintsev
On Sun, Nov 27, 2016 at 12:07 PM, Michael Van Canneyt <
mich...@freepascal.org> wrote:
>
> If you mean in a cross-platform way, I think we would welcome patches :)
>
> On the subject of cross-platform console applications...

While working recently on converting libwebsockets header to FPC, I ran
into a need of adding Ctrl-Break handlers (used in sample apps).
I was actually surprised of the presence of SysSetCtrlBreakHandler function
in RTL.
But i was even more surprised it doesn't do anything useful (for console
application).

So here's the first patch for Windows
http://bugs.freepascal.org/view.php?id=31023

If this one is good (or made to the state, when it's good), I'm looking
into providing the same patches for linux and darwin.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Dmitry Boyarintsev
On Sun, Nov 27, 2016 at 8:24 AM, Adriaan van Os  wrote:

> I wonder what the recommended way is to readln a password from console, as
> a standard Readln echoes the password.
>
> 1. SetConsoleMode seems to be Windows-specific
>

I'd think you want something simlar on unix.
Take a look at man 4 termios
specifically at local flag named "ECHO".
you want to disable it via tcsetattr()  (TermIO unit)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Underscores in numerical literals - grouping

2016-11-21 Thread Dmitry Boyarintsev
On Mon, Nov 21, 2016 at 9:46 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> I don't know about you, but I like this idea implemented in Java 7 and
> later.
>
> http://jasdhir.blogspot.co.uk/2016/11/using-underscores-in-literals.html
>
>
> I always find it hard to read long numeric literals.
>

I find it a made up problem, inspired by sales department.

The site shows CC-card and SSN number stored as numerics. I doubt there's
ever a task that actually needs such storage (since both numbers should be
considered as a set of characters ie strings).

Maybe its a new feature that will inspire people to use more anonymous
constants.
They looked ugly before, but look how cute they look now if underscores.

Having pure-functions available for pascal constant expressions is far more
preferred than underscores.
And it will also might make them even more readable and flexible.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] LLVM Backend Support

2016-08-31 Thread Dmitry Boyarintsev
On Wed, Aug 31, 2016 at 6:15 PM, African Wild Dog 
wrote:

> Again,thanks for the detailed explanation. As this is a recurrent
> topic,maybe it would be a good ideia to create a wiki page with all these
> points.
>

http://wiki.freepascal.org/LLVM

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] RTF writer

2016-08-05 Thread Dmitry Boyarintsev
On Fri, Aug 5, 2016 at 3:11 AM, Torsten Bonde Christiansen 
wrote:

> I am looking for at component that can write RTF format, preferably like
> the TRichMemo:
>
> http://wiki.lazarus.freepascal.org/RichMemo
>
> but without the need for LCL.
>
> In fpc 3.0 there is a RTF reader, but i have not been able to find a
> writer.
>

If nothing comes up, you could RichMemo sources as a starting point.
Look at richmemortf.pas specifically for IntSaveStream.
It accepts TRIchMemo component but only as a source of text+styles
information and could be replaced easily with your source of text+style.
The rest of the code is non rich memo specific

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Microsecond Delay Suggestions?

2016-07-26 Thread Dmitry Boyarintsev
On Tue, Jul 26, 2016 at 1:58 PM, James Richters <
ja...@productionautomation.net> wrote:

> I think there may be a solution with this performance counter for my
> purposes…  here’s what I’m trying to accomplish:
>
Well, Windows provides a different means of waiting (and waiting with time
out) for the Serial port communication.

The whole topic is discussed here:
https://msdn.microsoft.com/en-us/library/ff802693.aspx#serial_topic1

I'm thinking that using performance counter is a little of over-engineering

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Microsecond Delay Suggestions?

2016-07-26 Thread Dmitry Boyarintsev
On Tue, Jul 26, 2016 at 12:38 PM, James Richters <
ja...@productionautomation.net> wrote:

> What I need is a timer that I can specify in microseconds, a millisecond
> is too long.   I am using it for timing to read in a string on a serial
> connection.  My fastest baudrate is 25, so at that rate I would need to
> delay only 36 microseconds.  So I can’t use sleep () or delay () because
> they only go down to 1mS and that’s too slow.
>

Here's an example of Sleep with microseconds that I came up with

procedure SleepMcs(mcs: Int64);
var
  ct : TLargeInteger;
  fr : TLargeInteger;
  af  : TLargeInteger;
  trg : TLargeInteger;
const
  NanoInMicro = 1000;
begin
  QueryPerformanceCounter(ct);
  QueryPerformanceFrequency(fr);
  trg:=round(mcs * NanoInMicro / (NSInSec/fr));
  repeat
QueryPerformanceCounter(af);
  until trg<=(af-ct);
end;

I'm hoping that there's a better solution out there, because this procedure
will end up with 100% CPU load.
I doubt it's possible to unload the CPU, since the windows scheduler is in
milliseconds accuracy.
May be a lower (kernel/driver) level allows that.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Microsecond Delay Suggestions?

2016-07-26 Thread Dmitry Boyarintsev
On Tue, Jul 26, 2016 at 11:21 AM, Dmitry Boyarintsev <
skalogryz.li...@gmail.com> wrote:

> Maybe you want to look into QueryPerformanceCounter.
>
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx
>
> Here's an example:

{$mode objfpc}{$H+}

uses
  Windows;

const
  MSInSec = 1000;
  MCInSec = MSInSec * 1000;
  NSInSec = MCInSec * 1000;

function LargeLoop: Integer;
var
  i : integer;
begin
  Result:=0;
  for i:=0 to 1000 do
inc(Result);
   //or you can verify Sleep(milliseconds)
   //Sleep(100);
end;

var
  fr : TLargeInteger;
  ct : TLargeInteger;
  af : TLargeInteger;
  d  : double;
  diff : TLargeInteger;
begin
  QueryPerformanceFrequency(fr);
  writeln('Frequency: ' ,fr);
  d:=(1/fr) * NSInSec;
  writeln('Freq in Time: ', d:0:0, ' ns (roughly)');
  QueryPerformanceCounter(ct);
  LargeLoop;
  QueryPerformanceCounter(af);
  diff := af - ct;
  writeln('Loop:');
  writeln('  Ticks: ', diff);
  writeln('  Time:  ', ((diff/fr) * NSInSec):0:0,' ns' );
  writeln(' ', ((diff/fr) * MCInSec):0:6,' mcs' );
  writeln(' ', ((diff/fr) * MSInSec):0:6,' ms' );
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Microsecond Delay Suggestions?

2016-07-26 Thread Dmitry Boyarintsev
On Tue, Jul 26, 2016 at 11:19 AM, Dmitry Boyarintsev <
skalogryz.li...@gmail.com> wrote:

> On Tue, Jul 26, 2016 at 11:16 AM, James Richters <
> ja...@productionautomation.net> wrote:
>
>> Any suggestions on how to do this on windows with a console application?
>>
>
> I don't have an answer, but I'm wondering what kind of task is that?
> Why do you need this 55mS tick?
>
Maybe you want to look into QueryPerformanceCounter.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Microsecond Delay Suggestions?

2016-07-26 Thread Dmitry Boyarintsev
On Tue, Jul 26, 2016 at 11:16 AM, James Richters <
ja...@productionautomation.net> wrote:

> Any suggestions on how to do this on windows with a console application?
>

I don't have an answer, but I'm wondering what kind of task is that?
Why do you need this 55mS tick?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] OData and Office365 REST API support

2016-07-11 Thread Dmitry Boyarintsev
On Mon, Jul 11, 2016 at 5:12 PM, Michael Van Canneyt  wrote:

> I am VERY glad you asked this question. I had the same consideration when
> creating it :-) :-)
> [snip]
>
Got it. Thank you for clarification.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] OData and Office365 REST API support

2016-07-11 Thread Dmitry Boyarintsev
On Mon, Jul 11, 2016 at 2:32 PM, Michael Van Canneyt  wrote:

> As such, I consider web APIs an essential part of the compiler (or indeed
> any) toolchain. In fact I think FPC is woefully behind in this department...
>

Then I have API design question.Is it possible not to bind web-apis to
fcl-web package?

If my application is already using some other HTTP library (synapse or
indy), I'd like to keep using it, even for the new API, rather than having
code duplicating functionality (which would be fcl-web).

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] OData and Office365 REST API support

2016-07-11 Thread Dmitry Boyarintsev
On Mon, Jul 11, 2016 at 1:05 PM, Michael Van Canneyt  wrote:

>
> googleapis also does not have an own repository ?
>
> They don't, but maybe they should.
It's just taking more and more time to check out trunk.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] OData and Office365 REST API support

2016-07-11 Thread Dmitry Boyarintsev
On Mon, Jul 11, 2016 at 10:50 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:

> Long overdue, I have finally committed the initial version of the odata
> package in the FPC repository.
>

Is it worth its own repository, similar to googleapis?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Google AdMob for iOS

2016-07-06 Thread Dmitry Boyarintsev
Hello,

I did a little search and didn't find any headers of iOS AdMob for FPC.
It's Objective-C interface.

Thus, I converted them myself:
https://github.com/skalogryz/admob-pascal

Note, the conversion is incomplete, I stopped after converting Interstitial
Ad (which I needed).
If you need some other API of the framework, let me know and I can finish
the conversion for you.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] What to use when porting WaitForMultipleObjects to Linux?

2016-05-16 Thread Dmitry Boyarintsev
On Mon, May 16, 2016 at 9:01 AM, Bo Berglund  wrote:

> The Execute procedure handles everything going on and it acts on event
> signals picked up (I believe) by the WaitForMultipleObjects calls.
>
> What I would like to know is how exactly to handle this in FreePascal
> on Linux
>

I presume  FConnectEvent, FDisconnectEvent (and others) are of TEvent type
(from FCLs syncobjs)

In this case, I'd think you could implement WaitForMultipleObjects()
yourself, via a simple event waiting loop:

uses ... syncobjs, SysUtils ;

const
  WAIT_TIMEOUT = $102;

function WaitForMultipleObject(cnt : integer; const handle: array of
TEventHandle;
  waitforall: Boolean; timeOutMls: integer): integer;
var
  event : Integer;
  evNum : integer;
  i : integer;
  ev: array of boolean;
  wr: TWaitResult;
  any   : Boolean;
  d : TDateTime; // please forgive the usage of now() :)
  dm: integer;
const
  YIELD_TIME=0;
begin
  evNum:=0;
  SetLength(ev, cnt);
  Result:=WAIT_TIMEOUT;
  // create a loop of waiting for each event to fire
  repeat
any:=false;
if timeOutMls>0 then d:=now;

for i:=0 to cnt-1 do
  if not ev[i] then begin
// refer to synobj sources for .WaitFor() method of TEvent
wr:=TWaitResult(basiceventWaitFor(0, Handle[i]));
if wr=wrSignaled then begin
  ev[i]:=true;
  inc(evNum);
  Result:=i;
  if not waitforall then Break;
end;
  end;

if not any and (timeOutMls>0) then begin
  // if has timeout, must yeld the time for some time
  // and then repeat the try
  Sleep(YIELD_TIME);
  if timeOutMls>0 then begin
d:=now-d;
dm:=round(d*MSecsPerDay);
dec(timeOutMls, dm);
if (timeOutMls<0) then timeOutMls:=0;
  end;
end;
// btw, actual support for "waitforall" is not needed in this case
  until (evNum>0) and (not waitforall or (cnt=evNum)) or (timeOutMls=0);
  if waitforall and (evNum>0) then Result:=0;
end;

I've not tested this loop, but it should give you an idea of what you could
do.

The fact that you're using the handles of the same type allows you to
implement the loop yourself.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] What to use when porting WaitForMultipleObjects to Linux?

2016-05-16 Thread Dmitry Boyarintsev
On Mon, May 16, 2016 at 6:22 AM, Bo Berglund  wrote:

> When porting a Delphi console program on Windows to FreePascal on
> Linux, what can one do with API calls like WaitForMultipleObjects,
> which is used to synchronize processing between threads?
>

It depends if you're actually using WaitForMultipleObjects to sync with
*multiple* objects.
AFAIK, Posix API (implemented by Linux)  do not have any routine to
handle/sync multiple objects at the same.
Thus you might need to build something similar yourself.

The closest API in linux system is select() function, that can check the
status of multiple file-descriptors in one call. Some of file-descriptor
objects could be used for synchronization purposes.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] TJSONboolean and locale settings

2016-05-13 Thread Dmitry Boyarintsev
On Fri, May 13, 2016 at 10:32 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> So does the JSON Standard define saved boolean values as hard-coded
> English “True” and “False” values, no matter the locale?
>

What's case where "true"/"false" are localized?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] intel vs att asm (fstp instruction) (osx/clang features)

2016-05-04 Thread Dmitry Boyarintsev
On Wed, May 4, 2016 at 6:14 AM, Pierre Free Pascal 
wrote:

> I think the correct solution for you is to use explicit size information:
>
>
>
>   FSTP SINGLE PTR [EDX]
>
>   FSTP SINGLE PTR [EAX]
>
Indeed that worked as expected. Thank you.


> but
>
>   FSTP [s]
>
> and
>
>   FSTP [c]
>
It still requires explicit size information, like
   FSTP SINGLE [s]


>   My GNU as version 2.26 does not seem to need an explicit size,
>
> but I don’t know what Xcode uses, isn’t it also a GNU assembler?
>
> Could you tell us which assembler is used?
>

It's Apple's clang IIRC Apple stopped using gnu-tools since Xcode 3.2 or
something like that.
Here are more exact details:

$ as -v
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1as -triple x86_64-apple-macosx10.11.0 -filetype obj -main-file-name -
-target-cpu core2 -dwarf-version=2 -fdebug-compilation-dir
/Users/dmitry/FPC_Laz -dwarf-debug-producer Apple LLVM version 7.3.0
(clang-703.0.29) -mrelocation-model pic -o a.out -

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FCL: moving FastHTMLParser

2016-05-04 Thread Dmitry Boyarintsev
On Wed, May 4, 2016 at 10:36 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

>   FPC manages to find in somehow (not sure how yet - FPC magic ).
>

Isn't it in fpc.cfg?
-Fu/usr/local/bin/x.x.x/units/$fpctarget/*

That's forcing FPC to look through all compiled packages.
Since fasthtmlparser.o and fasthtmlparser.ppu are found at:
   /usr/local/bin/x.x.x/units/$fpctarget/chm/
it allows you to use it "out of the box".

thanks,
Dmitry

P.S: /usr/local/bin should be replaced with the proper FPC installation
folder. and "x.x.x" with the proper FPC version.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] intel vs att asm (fstp instruction) (osx/clang features)

2016-05-03 Thread Dmitry Boyarintsev
Hello,

I'm dealing with the following code (from ZenGL library), targeting OSX
---
{$mode delphi}

procedure m_SinCos( Angle : Single; out s, c : Single ); assembler;
asm
  FLD Angle
  FSINCOS
  FSTP [EDX]
  FSTP [EAX]
end;

var
  s,c: single;
begin
  m_SinCos(0,s,c);
end.
---

The latest Xcode 7.0 tools does recognize the generated assembler (fpc
trunk):
-
# [5] FLD Angle
flds 8(%ebp)
# [6] FSINCOS
fsincos
# [7] FSTP [EDX]
fstp (%edx)
# [8] FSTP [EAX]
fstp (%eax)
-

as a problem:

Assembling program
test.s:21:2: error: ambiguous instructions require an explicit suffix
(could be 'fstps', 'fstpl', or 'fstpt')
fstp(%edx)
^
test.s:23:2: error: ambiguous instructions require an explicit suffix
(could be 'fstps', 'fstpl', or 'fstpt')
fstp(%eax)

One interested could search the internet for the problem encountered with
other platforms, and find out that the newer clang is somewhat backward
incompatible.

My first attempt was to replace to put the suggested FSTPS instruction in
place:
FSTPS [EDX]
However, the compiler stopped me, complaining about "FSTPS" is not a
recognized instruction.

The next approach was to rewrite the function into at syntax. (The actual
implementation could be found at sincos() of RTL math unit).

Is it a yet to be developed feature for FPC to satisfy demands of external
tools relies on?

I presume since the compiler parses intel asm and translates it into at
asm, it should take into consideration requirements of the latest osx
building tools.
Or is it already supported and I'm just missing a compiler switch?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] c-blocks odd hints

2016-04-23 Thread Dmitry Boyarintsev
Hello,

The compiler seems to generate odd hints:

Local absolutevar "FPC_BLOCK_SELF" is not used

Here's the code.

if Assigned(gc.extendedGamepad) then
  gc.extendedGamepad.setValueChangedHandler(GamePadChange)
else if Assigned(gc.gamepad) then  // <-- hint here
  gc.gamepad.setValueChangedHandler(GamePadChange);
gc.setControllerPausedHandler(PauseHandler);  // <--hint here

Why?

PauseHandler and GamePadChange are procedures:
procedure GamePadChange(pad: GCGamePad; el: GCControllerElement);
procedure PauseHandler(gc: GCController);

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-16 Thread Dmitry Boyarintsev
On Sat, Apr 16, 2016 at 2:28 PM, Jürgen Hestermann <
juergen.hesterm...@gmx.de> wrote:

> I don't know what you mean.
> A For-loop has it's limits anyway.
> And when decrementing 'manually' I would stop if INDEX=0.
> For 0-based arrays I would stop if INDEX=-1?
> What would be different?
> For 1-based arrays I would never get an index<0
> because it stops at zero.


The problem is with using "unsigned" as an index (rather than zero- vs one-
based arrays)
Take a while loop as an example, where index can change multiple times.

Current solution:
while i>=0 do
  if cond then dec(i);
  dec(i);
end;

Unsigned index solution
while i>=0 do
  if cond then if i>0 then dec(i);
  if i>0 then dec(i);
end;

Without these checks, unsigned integer would loop over to $ and
will continue.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Any chance to add the TStringBuilder to FCL?

2016-04-15 Thread Dmitry Boyarintsev
On Fri, Apr 15, 2016 at 1:19 PM, Jürgen Hestermann <
juergen.hesterm...@gmx.de> wrote:

>
> So why do we need {$ZeroBasedStrings On} at all? ;-)
>

The same reason as other FPC features - (some of) Delphi code
compatibility.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Framework for Objects Serialization / Deserialization

2016-04-01 Thread Dmitry Boyarintsev
On Fri, Apr 1, 2016 at 9:51 AM, Mazola Winstrol 
wrote:

> I can't change the actual hierarchical structure of my classes so i can't
> use TComponent.
>
> Delphi do have an intersting way to do with serialization: they have some
> standard classes (TTypeMashaller, TConverter). If one wants to serialize to
> a new format (e.g binary format), one can extended those base classes and
> implement such serialization. Would be interesting if we create an
> infrastructure like that.
>

That might be handy.

In order to support Xcode project file (.pbx) structures I had to create a
stand-alone (de)serializers from scratch.
It's RTTI dependent, but is not based of TComponent.
It would also not fail, if encounters unrecognized property, instead would
keep it for the later serialization ( .pbx is undocumented and could change
without notice )

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Class constructor called unconditionally

2016-03-31 Thread Dmitry Boyarintsev
On Thu, Mar 31, 2016 at 11:28 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2016-03-31 16:06, Michael Van Canneyt wrote:
> > I usually have a 'Start Application' kind of routine where I register all
> > the necessary things, link things together (needed if you follow 'loosely
> > coupled' design).
>
> I do the same. The tiOPF project follows a similar path in the core
> framework and its UnitTest suite. It works well.
>

One could use an alternative approach and have "binding" units.
The unit would consist of initialization section only, that does the
necessary binding code.

They allow to avoid code within "start application" routine across
different projects.
At the same time they keep the actual library units free of initialization.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] History of the Cardinal data type?

2016-03-30 Thread Dmitry Boyarintsev
On Wed, Mar 30, 2016 at 4:37 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> In my case I'm specifically referring to the benefit of using (U)Int
> style data types for use in record structures when reading binary data
> files.
>
Makes sense.


> Does FPC follow that platform rule, or does FPC always define Word as
> 16-bits? [sorry I don't have a ARM device to test on at the moment]
> If Word size does changes in FPC (for example between x86 & ARMv6), then
> I have quite a bit of code to fix up.
>
Word is always 16-bit.
As Nikolay mentioned, the choice was made by Borland to keep word 16bit
even for 32-bit platforms.
GNU Pascal have Word 32-bit (http://www.gnu-pascal.de/gpc/Word.html)

Not sure if FPC support 32-bit in gnu mode. But ISO mode seems to keep it
at 16bit.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] History of the Cardinal data type?

2016-03-29 Thread Dmitry Boyarintsev
On Tue, Mar 29, 2016 at 9:06 PM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> So I definitely see the benefit in using (U)Int style data types.
> They are a lot more obvious [to the programmer] regarding data ranges
> and byte size.
>

Does, it also make the code less high-level?
Didn't high level use the platform independent notation such as "int" or
"word" to be portable across different platforms back in 60s 70s?
At that time word size might vary dramatically from system to system   (
https://en.wikipedia.org/wiki/Word_(computer_architecture) )
Thus a code written like this:
  a: Int32;
would not be portable, since it requires a target platform to support
32-bit word (or at least the compiler had to be smart enough).

The modern generation of developers doesn't really have to deal with that
too much, due to dominance of 32-bit (as well as virtual machines, such as
java and/or .net).
But jump to 64-bit still caused a bit of confusion (in C/C++ and object
pascal). with type names and sizes.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] History of the Cardinal data type?

2016-03-29 Thread Dmitry Boyarintsev
On Tue, Mar 29, 2016 at 11:31 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2016-03-29 16:17, Dmitry Boyarintsev wrote:
> > In Delphi world LongWord is 64-bit on 64-bit iOS platform and it is
> 32-bit
> > on 64-bit Windows platform.
>
> So what happened when they introduced Android support? Yet another
> definition or copied one of the others?
>

>From what I can see they currently support 32-bit processors for Android
devices.
(
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Android_Devices_Supported_for_Application_Development
)
So Cardinal is still 32-bit there.  I'd think it will grow to 64-bit as
soon as arm64 is supported.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] History of the Cardinal data type?

2016-03-29 Thread Dmitry Boyarintsev
On Tue, Mar 29, 2016 at 11:20 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:

>
> Which is quite confusing and a really bad decision.
> Basic integer types should not depend on the OS. On the CPU, yes.
>
> I guess they tried to make iOS platform a selling point and be more
C-like.
Just to remember that Strings are zero-based there, by default.

I believe this came with anticipation that the platform will not use (much)
of existing code base.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] History of the Cardinal data type?

2016-03-29 Thread Dmitry Boyarintsev
On Tue, Mar 29, 2016 at 11:06 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> So why does the Object Pascal language have a Cardinal type? Why
> couldn't LongWord be used instead?
>
In Delphi world LongWord is 64-bit on 64-bit iOS platform and it is 32-bit
on 64-bit Windows platform.

http://docwiki.embarcadero.com/RADStudio/XE8/en/What's_New#Changes_in_LongInt_and_LongWord_Size_for_64-bit_iOS_Platforms

Who know what it would be for future Linux 64 target?!
Thus using LongWord as 32-bit for Delphi is quite volatile.

Cardinal is instead always 32-bit
http://docwiki.embarcadero.com/Libraries/XE8/en/System.Cardinal

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-26 Thread Dmitry Boyarintsev
On Fri, Feb 26, 2016 at 10:38 PM, Mazola Winstrol 
wrote:

> In the code bellow, the generic type TNullableTyple is implemented (and
> incomplete for now).
>
How to reset TNullableType to Null value? HasValue seems to be read-only.


> Is there any possibility of "nullable types" be added to RTL or anyother
> fpc provided package?
>

You could start your own package separate from RTL.
It's not about where the package is hosted, it's about letting others know
that the package exists.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Wiki upgraded

2016-02-21 Thread Dmitry Boyarintsev
On Sat, Feb 20, 2016 at 5:50 PM, Jonas Maebe 
wrote:

> The wiki has been upgraded to MediaWiki 1.23


Great! thank you!
Is it possible to enable Subpages ? (
https://www.mediawiki.org/wiki/Help:Subpages)

Purpose - hierarchical organization of the knowledge base.
For example, all the pages of the book (
http://wiki.lazarus.freepascal.org/Object_Pascal_Tutorial) would be better
to implement as sub pages, rather than within the global wiki name scope.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to pass an array of bytes directly in a TBytes param?

2016-02-19 Thread Dmitry Boyarintsev
procedure test(const b: array of byte) ??

On Friday, February 19, 2016, silvioprog  wrote:

> Hello,
>
> Consider the following procedure:
>
> procedure test(b: TBytes);
> begin
> end;
>
> The common way to pass an array of bytes in this procedure is declaring
> and initializing a TBytes variable. But in Delphi (XE) I just do:
>
>   test([65, 66, 67]);
>
> However, when I try it on FPC (trunk), I get:
>
> "Error: Incompatible type for arg no. 1: Got "{Array Of Const/Constant
> Open} Array of ShortInt", expected "TBytes"".
>
> Is this feature supported in FPC? If so, how to use that?!
>
> Thank you!
>
> --
> Silvio Clécio
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Happy tickets benchmark

2016-02-15 Thread Dmitry Boyarintsev
On Sun, Feb 14, 2016 at 4:45 AM, Mattias Gaertner  wrote:

> Maybe documentation helps here.
>
> Is there already a page "pimp my fpc"?
>

In fact there's but.
http://wiki.freepascal.org/Improving_language_shootout_results

But the information is a bit outdated.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Please someone explain this to me

2016-02-10 Thread Dmitry Boyarintsev
On Wed, Feb 10, 2016 at 3:32 PM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2016-02-10 19:20, Michael Van Canneyt wrote:
> > You just need to look at the system or sysutils units from recent
> delphis to
> > see why include files are the better option,
> As someone that doesn't have access to recent Delphi versions, would you
> mind sharing a small example if you can.
>

It would be odd if they're using includes heavily.

It feels like namespaces should've resolved the problem.
Thus includes are replaced by namespaces, since it **should** keep
unit-like code structure.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-04 Thread Dmitry Boyarintsev
On Thu, Feb 4, 2016 at 2:44 PM, John Lee  wrote:

> luddite_clique 1 progressives 0
>
> Just wait for Delphi to implement this... speaking of which, why they've
not done it a long time ago?
They could, but probably didn't do that, for very likely the same reasons.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] if-then-else expression

2016-02-03 Thread Dmitry Boyarintsev
On Wed, Feb 3, 2016 at 6:11 AM, Serguei TARASSOV  wrote:

> Holy sh*t, ça continue ! :)
>

it's finally on the forum as well
http://forum.lazarus.freepascal.org/index.php/topic,31367.msg200825/topicseen.html#new

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] if-then-else expression

2016-02-02 Thread Dmitry Boyarintsev
On Tue, Feb 2, 2016 at 4:07 PM, geneb  wrote:

I probably missed it, but what problem is "IfThen()" actually solving?
>
> It's a sugar syntax, for

if cond then
  x:= a
else
  x:=b;

Just follow this thread:
http://lists.freepascal.org/pipermail/fpc-pascal/2016-January/046375.html

Pro #1: shortness of script
Pro #2: easier porting of C-style code (with ternary ? operator. Pascal
doesn't have an equivalent
https://en.wikipedia.org/wiki/%3F:#Programming_languages_without_the_conditional_operator
)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-02 Thread Dmitry Boyarintsev
On Tue, Feb 2, 2016 at 7:45 AM, Henry Vermaak 
wrote:

> Exceptions to standard behaviour is bad, just because there are
> exceptions doesn't mean that we need to create more of them.
> Documenting something doesn't make the behaviour intuitive.
>
> Too many exceptions create a rule? :)

I'd suspect that both if-else-experssion and iif() will end up being in the
FPC.
Since it appears that preference is split exactly 50/50 over an expression
and a function.

Similar to other duplication:
...in sets
  Include(ch, 'a')
  ch:=ch+['a'];

...in arithmetical operations
   a:=a+4;
   inc(a,4);
   a+=4;   // C-style btw!

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Dmitry Boyarintsev
On Mon, Feb 1, 2016 at 2:47 PM, Sven Barth 
wrote:

> If we would go the route of such an if-expression instead of an
> intrinsic then just leave away the "inline". That's absolutely not
> needed... (Note: implementation wouldn't be hard at all)
>

something like this:

if if true then true else false and if false then false else true then
  writeln('syntax hurts my eyes?')

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Pascal Lexical Diagrams

2016-02-01 Thread Dmitry Boyarintsev
On Mon, Feb 1, 2016 at 10:19 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2016-02-01 14:59, Dmitry Boyarintsev wrote:
> >
> > Could you please categorize any page as "outdated"?
>
> Is there a "outdated" category? If not, I don't know how to add new
> categories.
>
The category is there now.
In order to categorize a page just edit it and add

[[Category:Outdated]]

to the end of the page.


> The problem is that some pages are completely out of date, others have
> out of date images (eg: screenshots of lazaras dialogs), and others
> might have a section of text out of date.
>

Potentially, images could be categorized as well. Once found, it won't be
forgotten.


> Do all those get categorised as out of date, or should only whole pages
> be marked as such? If the latter, that might help to some extent, but
> would be far from a real solution.
>
It's better to mark, if the whole page is outdated.
Maybe create "Partial Outdated" category for the pages where only part of
information is not up to date.


> The bottom line is, Lazarus needs an actual documentation solution (per
> release, like FPC, fpGUI etc) - the wiki is not, and never will be that.
>
There're no releases in knowledge base. Live and learn :)

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Pascal Lexical Diagrams

2016-02-01 Thread Dmitry Boyarintsev
On Mon, Feb 1, 2016 at 4:32 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

> On 2016-01-30 19:12, Michael Van Canneyt wrote:
> > Wikimedia is NOT documentation. It is a knowledgebase.
>
> +1000
>
> The Lazarus project just doesn't seem to get that. The Lazarus wiki has
> so much broken or outdated information, no offline support, no
> documentation per Lazarus release. The list off "broken" things are
> getting longer and longer.
>

Could you please categorize any page as "outdated"?

So later any page within the category could be considered for either update
or removal.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] New feature: IfThen() intrinsic

2016-02-01 Thread Dmitry Boyarintsev
On Mon, Feb 1, 2016 at 1:23 PM, silvioprog  wrote:

>
> It would be nice if the programmer could choose it from some compiler
> switch, something like:
>
> {$define ifthendecl := InlineIf}
>
> macros?

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] raw socket example

2015-11-18 Thread Dmitry Boyarintsev
On Wed, Nov 18, 2015 at 12:45 PM, Daniel Gaspary  wrote:

> Need to change the fpsocket function call.
>
>
> From fpSocket(AF_INET,SOCK_STREAM,0)
> to fpSocket(AF_INET,SOCK_RAW,0);
>
> Is possible that the "0" needs to be changed too.
>

Just keep in mind that reading such socket is tricky.
There's no more IP address (as shown in the example).
The whole protocol stack needs to be handled manually.

I don't think there's any publish FPC raw-socket example.
The easiest way is to find C raw-socket example and port it to pascal.

thanks,
Dmitry
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

  1   2   3   >