Re: [fpc-pascal] Traits Proposal

2021-02-15 Thread Marcos Douglas B. Santos via fpc-pascal
On Mon, Feb 15, 2021 at 12:52 PM Ryan Joseph via fpc-pascal
 wrote:
>
> > On Feb 14, 2021, at 11:43 PM, Sven Barth via fpc-pascal 
> >  wrote:
> >
> > Same names should be rejected. Providing a new implementation can be 
> > controlled using the interface alias:
> >
> > === code begin ===
> >
> > type
> >   TMyClass = class(TInterfacedObject, IMyIntf)
> >   private
> > fMyRecord: TMyRecord;
> >   public
> > procedure IMyIntf.Test2 = MyTest2;
> > // this will hoist all methods except Test2 from TMyRecord and MyTest2 
> > as Test2 from the class itself
> > property MyRecord: TMyRecord read fMyRecord implements IMyIntf; default;
> > propcedure MyTest2;
> >   end;
>
> So "procedure IMyIntf.Test2 = MyTest2;" basically tells the compiler to 
> ignore the duplicate name resections and then when it encounters the MyTest2 
> there is no error?
>
> A duplicate name in this context is basically just method hiding (like in 
> normal OOP) so you could argue it should be allowed. If the property came 
> before then the interface would hide the local declaration. Not too different 
> from how normal inheritance works really.
>

As I understand, this is not a method hiding, but just to tell the
compiler which method to implement the interface—the interface could
have method names which are very very common to use and this syntax
allows us to "rename" those methods without changing the original
names that the class might have.

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


Re: [fpc-pascal] New User

2020-11-30 Thread Marcos Douglas B. Santos via fpc-pascal
On Mon, Nov 30, 2020 at 4:43 AM Derek Stewart via fpc-pascal
 wrote:
>
> Hi,
>
> I have just discover FreePascal and compiled FPC from source. I must say
> it look very good.
>
> I did a software engineering course in the UK Open University, in the
> 1980s, which was mainly Pascal orientated.
>
> I am working my way through the excellent FPC tutorials.
>
> Can anyone recommend any good reference books on FPC.

https://castle-engine.io/modern_pascal_introduction.html

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] uses in '' relative paths

2020-10-08 Thread Marcos Douglas B. Santos via fpc-pascal
On Wed, Oct 7, 2020 at 2:02 PM Mattias Gaertner via fpc-pascal
 wrote:
>
> On Wed, 7 Oct 2020 10:53:16 -0600
> Ryan Joseph via fpc-pascal  wrote:
>
> > I'm trying "uses in" which I never knew existed before.
> >
> > The idea is that I provide a path to TOML.pas using -Fu then use the
> > "in" syntax to reference the units which are in a subdirectory. This
> > makes it safe from the project importing the unit so any private
> > units in the subdirectory don't override units from the importing
> > project.
> >
> > unit TOML;
> > interface
> > uses
> >   TOMLParser in '/sources',
> >   TOMLTypes in '/sources';
>
> uses
>   TOMLParser in 'sources/TOMLParser.pas',
>   TOMLTypes in 'sources/TOMLTypes.pas';
>
> Not Delphi compatible.

I think this works even on Delphi 7...

best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Developing a mini ERP / web based development

2019-06-27 Thread Marcos Douglas B. Santos
On Thu, Jun 27, 2019 at 7:58 PM Darius Blaszyk  wrote:
>>
>> You can use fpWeb, which came with FPC.
>
>  Great, is there any database master/detail example that I could use to learn?
> I have no idea yet how to program the visuals for such an application. Any 
> tips
> would be greatly appreciated!

fpWeb will be used in backend.
For the frontend you need to use HTML+CSS+JavaScript.

You can use pas2js, coding in Object Pascal, but generating JavaScript
for create views on the browser, as already mentioned.
However, I don't work much in front so, I don't have examples for you, sorry.

att,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Developing a mini ERP / web based development

2019-06-27 Thread Marcos Douglas B. Santos
On Thu, Jun 27, 2019 at 1:10 PM Darius Blaszyk  wrote:
>
> Hi all,
>
> I have been asked to write a limited functionality / mini ERP type of 
> software for an NGO that is setting up a hospital. I'm doing this in my own 
> time and free of charge. The compiler and IDE of choice are of course 
> FreePascal & Lazarus. I’m still thinking about the direction to go exactly 
> with this and I was hoping to get some feedback/support from the community 
> here as I always have gotten over the years.
>
> The hardware of choice is already made and will be a network of several 
> Chromebooks on which all staff will be logging in the system. This made me 
> think that a desktop application is less feasible and I should look at a 
> web-based solution. I found some frameworks such as ExtPascal, fano, Brook, 
> pas2js. Unfortunately, I don't know much about web-based applications. So my 
> question is whether any of the frameworks are mature enough to create a 
> database driven application as described. Possibly there are other frameworks 
> available that I don't know of but are worth investigating?
>
> As I am starting this endeavor I would welcome any advisory or practical 
> help. If someone is willing to support in any form, please contact me via PM.
>
> TIA for all pointers, tips, and suggestions.

Hello,

You can use fpWeb, which came with FPC.
I'm not sure if fpWeb documentation is updated and you need to pay
attention on it.
I'm saying that because the original ones uses DataModule + Actions,
like old Delphi WebBroker.
But you can use all new features of fpWeb, eg. Routes, instead of this
old WebBroker model.

I've wrote two simple articles about it, however written in Portuguese:
https://objectpascalprogramming.com/fpweb
https://objectpascalprogramming.com/fpweb-hello

I believe you can use Google Translator, though.

best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Error? No range checks in mode delphi?

2019-06-03 Thread Marcos Douglas B. Santos
On Mon, Jun 3, 2019 at 4:46 PM Anthony Walter  wrote:
>
> Is the following a bug in the compiler or a feature? Is would seem using 
> {$mode delphi} allows code which clearly violates range bound to compile 
> without error.
>
> program Project1;
>
> {$mode delphi}
>
> type
>   TSuit = (suHeart, suDiamond, suClub, suSpade);
>   TRedSuit = suHeart..suDiamond;
>
> var
>   Suit: TRedSuit;
> begin
>   // This should generate an error, but {$mode delphi} allows it
>   Suit := suClub;
> end.

Debugging option -> check Range (-Cr)

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] libmosquitto headers for FPC

2019-03-14 Thread Marcos Douglas B. Santos
On Thu, Mar 14, 2019 at 11:55 AM Karoly Balogh (Charlie/SGR)
 wrote:
>
> Hi,
>
> Not sure if anyone have done this already, but I converted the
> libmosquitto (which is a C-written MQTT client library) header
> (mosquitto.h) to Free Pascal, so it allows using libmosquitto from Pascal
> code. I work on some IoT projects lately which transfers data over MQTT,
> and I wanted to write some of the code in Pascal (after some other
> languages failed to meet expectations, business as usual), so I just did
> it. I know some Pascal MQTT libraries exist, but all I encountered seemed
> to have some limitations, or things I didn't like (being too Delphi
> centric, or something) and libmosquitto just seems to be much more used.
>
> Note this is only a pure conversion of the C header file using ctypes,
> with some pascalisms added (like proper callback function types). I have
> an additional class-layer on top of it planned, but so far I only got the
> headers converted, but they work in our internal project. I want to add
> some examples later too.
>
> So in case anyone needs this:
>
> http://github.com/chainq/mosquitto-p
>
> As we hopefully will soon use this in production, I sort of committed
> to keep the headers up-to-date.
>
> I tested it on Darwin (x86_64) and Linux (x86_64 and arm), but adding
> Windows support should be trivial. (Probably only needs the right .dll
> name added as linklib, or something.)

Good job.

I'm thinking use some like that to split a big desktop application
code into few other applications, maintaining a communication among
them.
Is it a good case to use mosquitto? If so, I can help you on Windows,
testing and etc.

best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Passing nested procs out?

2018-11-15 Thread Marcos Douglas B. Santos
On Thu, Nov 15, 2018 at 8:15 AM Sven Barth via fpc-pascal
 wrote:
>
> Am Do., 15. Nov. 2018, 10:17 hat Ryan Joseph  
> geschrieben:
>>
>> Is passing nested procs outside of the calling scope relying on undefined 
>> behavior? It doesn’t seem like this should be allowed.
>
>
> See the notes mentioned here: 
> http://wiki.freepascal.org/FPC_New_Features_2.6.0#Support_for_nested_procedure_variables
>
> Don't know if it is documented as such, but if not, it should be.

If I understood correctly, this can be used in all cases of anonymous
functions, with the advantage to make the code more readable and
"Pascalish".
Am I right?

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc.cfg using relative paths

2018-11-04 Thread Marcos Douglas B. Santos
On Sun, Nov 4, 2018 at 5:52 PM Fabio Luis Girardi
 wrote:
>
> Hi Marcos!
>
> I use a lot of FPC/Lazarus versions using one FPC.cfg file, but instead of 
> using relative paths, I use compiler variables, absolute paths, ext4 symlink 
> and directory structure equal to all versions. The unique thing that I have 
> to do each time when installing a new FPC version, is the symlink  to the 
> original fpc.cfg file.
>
> The unique problem is if these file is shared across multiple users.

For me, it must be relative paths.
I have different installed paths - even in different drivers.

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] fpc.cfg using relative paths

2018-11-04 Thread Marcos Douglas B. Santos
Is there, any change, to use relative paths inside fpc.cfg?
I have several Lazarus copies, in different paths, and I would like to
use the same fpc.cfg on all of them.

I've tried to use relative paths and macros but it hasn't worked.

best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Windows programming tutorials for FPC

2018-11-02 Thread Marcos Douglas B. Santos
On Fri, Nov 2, 2018 at 7:13 AM James  wrote:
>
> I've been programming for decades with Pascal, starting with Turbo Pascal, 
> and for a few years now with Freepascal, and even wrote really complicated 
> console windows programs with Freepascal that do windows function calls... 
> But now I find that I would like to write a few windows GUI programs,  and 
> well... I'm clueless... I never learned windows GUI programming and don't 
> have a clue about how it's done, it's always been faster and easier to just 
> keep doing what I already understand, but now I have a few applications to 
> write what would be much better suited to a native windows application, so,   
> I am wondering if there are any tutorials out there, hopefully specific to 
> Freepascal and/or Lazarus.  I need really basic stuff like how to open a 
> message box, or how to use windows file open, or save-as dialog boxes.. etc.. 
> even a hello world tutorial would be helpful... ok, so ZERO windows 
> programming experience here...   Any advice on where to start?
>

I've just search on Google:
https://www.win.tue.nl/~wstomv/edu/lazarus/dev_gui_app.html

Looks useful.

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Where can I download the fpc 3.0.0 seed compiler for Linux on i386 x64?

2018-10-23 Thread Marcos Douglas B. Santos
On Tue, Oct 23, 2018 at 12:02 PM Bo Berglund  wrote:
>
> I want to build FPC/Lazarus (3.0.4/1.8.4) from sources on a new Linux
> (Ubuntu 18.04 TLS MATE) using an i386 family CPU.
> AFAIK I need to have the fpc seed compiler in order to do this.
>
> But this is a hen and egg problem, how can I download the compiler
> needed to build 3.0.4 on this Linux machine?

The easiest way: fpcupdeluxe
https://github.com/newpascal/fpcupdeluxe/releases

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Parse strings like "day-1" to convert in a time stamp

2018-10-15 Thread Marcos Douglas B. Santos
On Mon, Oct 15, 2018 at 9:33 AM Michael Van Canneyt
 wrote:
>
> > On Sun, Oct 14, 2018 at 8:19 PM Michael Van Canneyt
> >  wrote:
> >>
> >>
> >>
> >> On Mon, 15 Oct 2018, Sven Barth via fpc-pascal wrote:
> >>
> >> > Marcos Douglas B. Santos  schrieb am So., 14. Okt.
> >> 2018,
> >> > 16:15:
> >> >
> >> >> Do you know any Pascal lib to parse strings to convert in date/time
> >> values?
> >> >> The user is supposed to type human-friendly values like:
> >> >> - "day"=> trunc(now)
> >> >> - "day-2" => trunc(now-2)
> >> >> - "week" => trunc(now-7)
> >> >> - "yesterday" => trunc(now-1)
> >> >> - etc...
> >> >> But they could type even their computer date format or ISO as well.
> >> >>
> >> >> A lib in C, but very complex:
> >> >> - https://github.com/gagern/gnulib/blob/master/lib/parse-datetime.y
> >> >>
> >> >> I would like to start with something simpler, if possible. Thank you.
> >> >>
> >> >
> >> > I don't know a specific library that fulfills your needs, but maybe
> >> you can
> >> > build something atop of FpExprPars:
> >> > http://wiki.lazarus.freepascal.org/How_To_Use_TFPExpressionParser
> >> > At least according to the source it also supports datetime handling.
> >
> > Thanks, Sven.
> >
> >>
> >> It does, it's used (amongst other things) in the reporting engine;
> >
> > Michael,
> > But does it work using just date values - accordingly with date format
> > in OS - or also with "day", "tomorrow", etc?
> > If not, can I extend those classes without change the original ones?
>
> All depends on the exact format you want to use.
> day -1
> can be easily implemented by registering a function day, which returns teh
> same Date()

So I can register those identifiers as functions, cool!

> double quotes are supported as delimiters for identifiers, so "Day" should
> work, but a date literal is going to be tricky.

Maybe I can test the value first if it is a valid date format, before
try to use FpExprPars on it...
It looks like a good start, though. Thanks.

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Parse strings like "day-1" to convert in a time stamp

2018-10-15 Thread Marcos Douglas B. Santos
On Sun, Oct 14, 2018 at 8:19 PM Michael Van Canneyt
 wrote:
>
>
>
> On Mon, 15 Oct 2018, Sven Barth via fpc-pascal wrote:
>
> > Marcos Douglas B. Santos  schrieb am So., 14. Okt. 2018,
> > 16:15:
> >
> >> Do you know any Pascal lib to parse strings to convert in date/time values?
> >> The user is supposed to type human-friendly values like:
> >> - "day"=> trunc(now)
> >> - "day-2" => trunc(now-2)
> >> - "week" => trunc(now-7)
> >> - "yesterday" => trunc(now-1)
> >> - etc...
> >> But they could type even their computer date format or ISO as well.
> >>
> >> A lib in C, but very complex:
> >> - https://github.com/gagern/gnulib/blob/master/lib/parse-datetime.y
> >>
> >> I would like to start with something simpler, if possible. Thank you.
> >>
> >
> > I don't know a specific library that fulfills your needs, but maybe you can
> > build something atop of FpExprPars:
> > http://wiki.lazarus.freepascal.org/How_To_Use_TFPExpressionParser
> > At least according to the source it also supports datetime handling.

Thanks, Sven.

>
> It does, it's used (amongst other things) in the reporting engine;

Michael,
But does it work using just date values - accordingly with date format
in OS - or also with "day", "tomorrow", etc?
If not, can I extend those classes without change the original ones?

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Parse strings like "day-1" to convert in a time stamp

2018-10-14 Thread Marcos Douglas B. Santos
Do you know any Pascal lib to parse strings to convert in date/time values?
The user is supposed to type human-friendly values like:
- "day"=> trunc(now)
- "day-2" => trunc(now-2)
- "week" => trunc(now-7)
- "yesterday" => trunc(now-1)
- etc...
But they could type even their computer date format or ISO as well.

A lib in C, but very complex:
- https://github.com/gagern/gnulib/blob/master/lib/parse-datetime.y

I would like to start with something simpler, if possible. Thank you.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Abstract method in TBufDataSet

2018-09-26 Thread Marcos Douglas B. Santos
Is it correct that TBufDataSet - a real component in Lazarus palette that
can be used as an instance - could have a abstract method or this is a
mistake?

bufdataset.pas(616,15) Hint: Found abstract method:
LoadBlobIntoBuffer(;TFieldDef;PBufBlobField);

If it is by design, do you consider normal see this hint when using it?

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Auto vars (again)

2018-08-18 Thread Marcos Douglas B. Santos
On Sat, Aug 18, 2018 at 2:04 PM, Ryan Joseph  wrote:
>
> How does TAutoFree in mORMot work? Never heard of this.

See 
http://blog.synopse.info/post/2014/11/14/Automatic-TSQLRecord-memory-handling

regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Split stream into words

2018-07-03 Thread Marcos Douglas B. Santos
On Tue, Jul 3, 2018 at 11:55 AM, Michael Van Canneyt
 wrote:
>
>> Thanks.
>> But, is uregexp part of FPC?
>
>
> Not yet, but I intend to make it so.

All right! Thanks.

Marcos Douglas

PS. Please, don't forget the XPath Unicode implementation too.
We have talked about it months ago... but I can imagine that your
to-do list is huge.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Daemon using TTimer on Windows

2018-07-03 Thread Marcos Douglas B. Santos
On Tue, Jul 3, 2018 at 11:36 AM, Giuliano Colla
 wrote:
> Il 03/07/2018 15:14, Marcos Douglas B. Santos ha scritto:
>
>> Can we sleep a thread for minutes or even hours without any problems?
>> The OS will not kill the thread?
>
> On Linux environment, sample situation on one of our servers:
>
>> ├─hald───hald-runner─┬─hald-addon-acpi │ ├─hald-addon-keyb │
>> └─2*[hald-addon-stor] 16:27:34 up 567 days, 20:40, 1 user, load average:
>> 0.02, 0.01, 0.00
>
>
> Hald threads are unused since 567 days (they're triggered by the insertion
> of new hardware, which never happened on our server) and are still there!
>
> On Windows a CTRL-ALT-DEL will show you a lot of useless threads activated
> at power on, and sleeping since then.
>
> OS may decide to swap them off, so that activation may be slower, but never
> to kill them.

Very interesting!

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

Re: [fpc-pascal] Split stream into words

2018-07-03 Thread Marcos Douglas B. Santos
On Tue, Jul 3, 2018 at 10:26 AM, Michael Van Canneyt
 wrote:
>
>
> On Tue, 3 Jul 2018, Marcos Douglas B. Santos wrote:
>
>> On Tue, Jul 3, 2018 at 7:50 AM, Michael Van Canneyt
>>  wrote:
>>>
>>>
>>> On Tue, 3 Jul 2018, Marco van de Voort wrote:
>>> Trivial indeed, till you need more fine-grained control.
>>> e.g. C needs to be an array of chars that mark word boundaries etc.
>>>
>>> But I managed to solve the problem with regexps...
>>
>>
>> How?
>
>
> I misunderstood how Split works. The regex is the 'word separator' in that
> function.
>
> The following correctly gives me all words. unit uregexp is the regexp unit
> compiled for unicode.

Thanks.
But, is uregexp part of FPC?

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

Re: [fpc-pascal] Split stream into words

2018-07-03 Thread Marcos Douglas B. Santos
On Tue, Jul 3, 2018 at 7:50 AM, Michael Van Canneyt
 wrote:
>
> On Tue, 3 Jul 2018, Marco van de Voort wrote:
> Trivial indeed, till you need more fine-grained control.
> e.g. C needs to be an array of chars that mark word boundaries etc.
>
> But I managed to solve the problem with regexps...

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

Re: [fpc-pascal] Daemon using TTimer on Windows

2018-07-03 Thread Marcos Douglas B. Santos
On Mon, Jul 2, 2018 at 6:28 PM, Marc Santhoff  wrote:
> On Sat, 2018-06-30 at 17:57 -0300, Marcos Douglas B. Santos wrote:
>>
>> My question is: Nowadays, can I use TTimer with no restrictions in a
>> daemon application on Windows? If not, which could be a possible
>> solution?
>>
>
> Some years ago Graeme G. posted a solution to that problem. It's attached to
> this mail, hoping hte list accepts pure text attachemnts, although I hoped it
> would have been integrated in fpc/lazarus.

I've received the file, thank you.

Can we sleep a thread for minutes or even hours without any problems?
The OS will not kill the thread?

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] TFPGObjectList error

2018-07-02 Thread Marcos Douglas B. Santos
On Mon, Jul 2, 2018 at 3:16 AM, Michael Van Canneyt
 wrote:
>
> [...]
>
> Contrary to what it may seem it is not so easy to make a search engine for
> the documentation. I've had several shots at it, but have not yet come up
> with a good mechanism. The last mechanism I tried ended up indexing more
> than 24 hours before I killed it.
>
> Contributions or ideas welcome.

I found this project 2 years ago but I've never tried to use:

https://github.com/AcoonDe/OpenAcoon

Maybe it could give you some ideas.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Daemon using TTimer on Windows

2018-07-01 Thread Marcos Douglas B. Santos
On Sun, Jul 1, 2018 at 2:15 AM, Martin Schreiber  wrote:
> On Saturday 30 June 2018 22:57:47 Marcos Douglas B. Santos wrote:
>
>>If not, which could be a possible
>> solution?
>>
> You could use a MSEgui application, instead of
> "
> uses
>  msegui;
> "
> write
> "
> uses
>  msenogui;
> "
> in "program" source file. It will have an event queue and the usual event
> driven programming paradigm including the use of datamodules and graphically
> placed non visual components. Examples are here:
>
> https://gitlab.com/mseide-msegui/mseuniverse/tree/master/attic/msedocumenting/mse/trunk/help/tutorials/nogui

Hey Martin, thanks to give me another good option. I'll check it.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Daemon using TTimer on Windows

2018-07-01 Thread Marcos Douglas B. Santos
On Sat, Jun 30, 2018 at 9:13 PM, R0b0t1  wrote:
> On Sat, Jun 30, 2018 at 3:57 PM, Marcos Douglas B. Santos
>  wrote:
>> Hi,
>>
>> I need to build a daemon app on Windows. It will need a timer to
>> performe some tasks. This timer could be big among 15 min, 30 min, 2
>> hours, etc.
>>
>> I thought that I can use TTimer but I've always heard that it's not
>> possible because some problems related with "NoGUI" stuff.
>>
>> I've found a thread[1] which talks about that but they haven't
>> provided a real solution, at least for Windows.
>>
>> My question is: Nowadays, can I use TTimer with no restrictions in a
>> daemon application on Windows? If not, which could be a possible
>> solution?
>>
>
> If all your service does is wait for the timer you should instead use
> a scheduled task.

Actually, it could be a better idea. I will check the requirements and
think if this would be possible.

> Anyway - does TTimer use the WM_TIMER message? That is the type tied
> to the GUI. Even if you need to use WM_TIMER for some reason you can,
> as services should be run in "session 0" and should have access to a
> GUI. The latter is, I think, a compatibility option you can enable.

I didn't understand this "session 0"... is it a something related to
Lazarus or Windows?

> If you are not opposed to OS-level primitives you should use waitable
> timers 
> (https://docs.microsoft.com/en-us/windows/desktop/sync/using-waitable-timer-objects).
> Using waitable timers you can also wake the computer from sleep.

I'm not opposed at all. Indeed I didn't know these functions... sounds
a good option. Thanks.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Daemon using TTimer on Windows

2018-06-30 Thread Marcos Douglas B. Santos
Hi,

I need to build a daemon app on Windows. It will need a timer to
performe some tasks. This timer could be big among 15 min, 30 min, 2
hours, etc.

I thought that I can use TTimer but I've always heard that it's not
possible because some problems related with "NoGUI" stuff.

I've found a thread[1] which talks about that but they haven't
provided a real solution, at least for Windows.

My question is: Nowadays, can I use TTimer with no restrictions in a
daemon application on Windows? If not, which could be a possible
solution?

Thanks.

[1] http://lists.freepascal.org/pipermail/fpc-pascal/2013-March/036823.html

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Proper preprocessor?

2018-06-24 Thread Marcos Douglas B. Santos
On Fri, Jun 22, 2018 at 6:47 PM, Sven Barth via fpc-pascal
 wrote:
>
>> [...]
>
> Why not simply test it?
>
> That said you can also do this:
>
> === code begin ===
>
> {$macro on}
>
> {$ifdef debug}
>   {$define foo := foo_debug}
> {$else}
>   {$define foo := foo_run}
> {$endif}
>
> uses
>   foo;
>
> begin
>   foo.SomeFunc;
> end.
>
> === code end ===
>
> Though more often than not such things are done by simply using a different
> set of units with the same names in a different unit path.

Because I was on the road, without my laptop, and I didn't want to
forget this :)
And your way is even better, thank you.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Proper preprocessor?

2018-06-22 Thread Marcos Douglas B. Santos
On Fri, Jun 22, 2018 at 5:13 PM, Florian Klämpfl  wrote:
>
> {$macro on}
>
> {$define TypeStr:=specialize _TypeStr}
>
> begin
>   Writeln(TypeStr);
> end.

Can I use the same idea but for units?

Like this:

{$macro on}

uses
  {$ifdef debug}
foo_debug
{$define foo := foo_debug}
  {else}
foo_run;
{$define foo := foo_run}
 {$enfif}

begin
  foo.SomeFunc;
end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Default record fields

2018-06-22 Thread Marcos Douglas B. Santos
On Fri, Jun 22, 2018 at 12:59 PM, Ralf Quint  wrote:
> On 6/22/2018 4:19 AM, Karoly Balogh (Charlie/SGR) wrote:
>>
>> Hi,
>>
>> On Fri, 22 Jun 2018, Ryan Joseph wrote:
>>
>>> I want to do a pivot away from the macro stuff to ask another question.
>>> Since I’ve wanted to contribute to the compiler for so long and I
>>> finally have a little understanding I’d like to know if there’s anything
>>> minor I could do, that isn’t offensive to the compiler team.
>>
>> It's not about the compiler team. It's about the integrity of a
>> programming language, which doesn't matter these days a lot, when all
>> languages turned into a feature race to provide the same broken concepts,
>> but with slightly different syntax. Nevermind. I sometimes do not even
>> understand how people did stuff for 50 years without
>> TObjectClassAdvancedTemplateGenericRecordRTTI...
>
> +1
> It's not (only/just) what "the compiler team" wants. There are people
> actually using the compiler. For real life purposes.
> And a lot of what people are proposing, over and over again, are solutions
> for problems that nobody has (in real life)...

+1
It is better to have a simple language with packages/libs to do the (real) job
than a complex language that try doing anything that someone could
imagine or want to do.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Better usage of "with"

2018-06-14 Thread Marcos Douglas B. Santos
On Thu, Jun 14, 2018 at 8:43 AM, Ryan Joseph  wrote:
>
[...]
> His premise for the proposal is that programming languages
> should help the programmer to make code which is better read
> by the CPU instead of high-level constructs for abstract concepts.
> It’s very specific to a particular task but very important for
> low-languages like c++ and Pascal which are close to the CPU.

It is the opposite: programming languages should help programmers
to make code which is better read by human being, not CPU.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] HTTPRoute.pas and TRouteObject

2018-06-03 Thread Marcos Douglas B. Santos
On Sun, Feb 11, 2018 at 4:24 AM, Kevin Jesshope  wrote:
>
> Thanks Michael,
>
> I did consider putting everything in the HandleRequest  but I prefer
> the virtual constructor.

I would like to suggest you do not use inherited classes from
TRouteObject as its business classes.
Inside HandleRequest you can instantiate any business classes that you
want and your code won't need fpWeb to test it. Make them separated.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Free e-book: Free Pascal from Square One

2018-05-29 Thread Marcos Douglas B. Santos
On Sun, May 27, 2018 at 1:18 PM, Jonas Maebe  wrote:
> Hi,
>
> See http://www.contrapositivediary.com/?p=4034
>
> It's by Jeff Duntemann, and based on his 1993 book "Borland Pascal 7 from
> Square One".

Thanks for sharing.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Class Helper to implement an Interface

2018-05-26 Thread Marcos Douglas B. Santos
On Sat, May 26, 2018 at 4:56 PM, Marco van de Voort <mar...@stack.nl> wrote:
> In our previous episode, Marcos Douglas B. Santos said:
>> Can I make a class helper to implements an Interface in an existing class?
>
> No, since a change to the class is needed (the tables with methods). Helpers
> are more an extra scope layered over the class without changing it.

All right. Thanks for this information.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Class Helper to implement an Interface

2018-05-26 Thread Marcos Douglas B. Santos
Hi,
Can I make a class helper to implements an Interface in an existing class?

For example, TStringList class has Find:

public function TStringList.Find(const S: string; out Index: Integer):Boolean;

Imagine an IFinder interface with the same method (only this method).
So, is it possible to make TStringList to implement IFinder using a
helper? If yes, which is the syntax?

Thanks,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-12 Thread Marcos Douglas B. Santos
On Wed, May 9, 2018 at 10:48 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Wed, 9 May 2018, Marcos Douglas B. Santos wrote:
>
>>>> OK sorry for didn't find this bugreport.
>>>> Is this fix in fixes_3_0 ?
>>>
>>>
>>>
>>> I do not know, presumably not.
>>
>>
>> For "new things" I use to use the last version published, just to see
>> that works.
>> Then, I start to use fixes_3_0.
>> I supposed that any fixes in trunk must be applied in fixes, don't?
>
>
> Not necessarily. It depends on the plans for the next release.
>
>>
>> Well, if I'm wrong, could you do that to this bug?
>
>
> Marco Van de Voort usually handles this.

Just for you and others know, it already was applied in fixes_3_0.
My FPC rev is 38816.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-09 Thread Marcos Douglas B. Santos
On Wed, May 9, 2018 at 9:31 AM, Michael Van Canneyt
 wrote:
>
>>
>> OK sorry for didn't find this bugreport.
>> Is this fix in fixes_3_0 ?
>
>
> I do not know, presumably not.

For "new things" I use to use the last version published, just to see
that works.
Then, I start to use fixes_3_0.
I supposed that any fixes in trunk must be applied in fixes, don't?

Well, if I'm wrong, could you do that to this bug?

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-09 Thread Marcos Douglas B. Santos
On Wed, May 9, 2018 at 3:47 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Tue, 8 May 2018, Marcos Douglas B. Santos wrote:
>
>> On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt
>> <mich...@freepascal.org> wrote:
>>>
>>>
>>>
>>> On Mon, 7 May 2018, Marcos Douglas B. Santos wrote:
>>>
>>>>>   Application.Run;
>>>>> end.
>>>>>
>>>>> ===END===
>>>>>
>>>>> My environment is:  Lazarus 1.8.3 r57764 FPC 3.0.4
>>>>> i386-win32-win32/win64
>>>>>
>>>>> Best regards,
>>>>> Marcos Douglas
>>>>
>>>>
>>>>
>>>> Michael,
>>>> Would you want that I open a issue for it?
>>>
>>>
>>>
>>> Allow me to test first, please.
>>
>>
>> All right.
>> Let me know if you need a tester or more information.
>
>
> I tested it.
>
> The memleak is present only in 3.0.4, no longer in trunk.
>
> I remembered a similar bugreport by African Wild Dog:
>
> https://bugs.freepascal.org/view.php?id=33535
>
> where I had the same conclusion.

OK sorry for didn't find this bugreport.
Is this fix in fixes_3_0 ?


On Wed, May 9, 2018 at 4:38 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
> [...]
> Small addendum: someone reported that in the transition to the use of
> routes, the registering of modules suddenly became case sensitive.
>
> I have fixed this, they are now case insensitive, but with the option to
> make it case sensitive. Also added the option to let an empty pattern match
> all URLS. Rev. 38956

All right, thanks for the info.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-08 Thread Marcos Douglas B. Santos
On Mon, May 7, 2018 at 6:05 PM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Mon, 7 May 2018, Marcos Douglas B. Santos wrote:
>
>>>   Application.Run;
>>> end.
>>>
>>> ===END===
>>>
>>> My environment is:  Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64
>>>
>>> Best regards,
>>> Marcos Douglas
>>
>>
>> Michael,
>> Would you want that I open a issue for it?
>
>
> Allow me to test first, please.

All right.
Let me know if you need a tester or more information.
Thanks for your time.

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

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-07 Thread Marcos Douglas B. Santos
On Sun, May 6, 2018 at 5:44 PM, Marcos Douglas B. Santos <m...@delfire.net> 
wrote:
> On Sat, May 5, 2018 at 11:51 AM, Michael Van Canneyt
> <mich...@freepascal.org> wrote:
>>
>>
>> On Sat, 5 May 2018, Marcos Douglas B. Santos wrote:
>>
>>> I'm using fpWeb in standalone mode (fphttpapp unit) to develop and debug.
>>> I would like to see the heaptrc log in the end, as we can do in normal
>>> desktop applications.
>>>
>>> So, in one route I create an object and don't release it to simulate a
>>> memleak.
>>>
>>> I've tried to set heaptrc.SetHeapTraceOutput('log.txt'). The app
>>> creates the file, but there is no log there.
>>
>>
>> This is definitely necessary.
>>
>>>
>>> I've tried to execute using F9 IDE and by command-line too.
>>> I think the problem is that we need to kill the server (Ctrl+C) and,
>>> because that, no log is created.
>>>
>>> So, how can I see the log?
>>
>>
>> Create a call that calls Application.Terminate.
>
> Michael,
>
> I believe there is a memleak but I couldn't found.
> I've just created a route that calls Application.Terminate and I got this:
>
> ===BEGIN===
> Heap dump by heaptrc unit
> 387 memory blocks allocated : 18658/19944
> 385 memory blocks freed : 18626/19912
> 2 unfreed memory blocks : 32
> True heap size : 196608 (96 used in System startup)
> True free heap : 196320
> Should be : 196352
> Call trace for block $034CA470 size 16
>   $0042D3C1
>   $00438926
>   $004375AA
>   $00437268
>   $004265FB
>   $BAADF00D
>   $BAADF00D
>   $BAADF00D
> Call trace for block $034CA410 size 16
>   $0042CE3B
>   $0042D3C1
>   $00438926
>   $004375AA
>   $00437268
>   $004265FB
>   $BAADF00D
>   $BAADF00D
>
> ===END===
>
>
> Here is my test program:
>
> ===BEGIN===
> program demo;
>
> {$define STANDALONE}
>
> uses
>   SysUtils,
>   httpdefs, httproute,
> {$ifdef STANDALONE}
>   fphttpapp,
> {$endif}
> {$ifdef FCGI}
>   fpfcgi,
> {$endif}
>   IniFiles;
>
> {$ifdef STANDALONE}
> procedure TerminateCallBack({%H-}ARequest: TRequest; {%H-}AResponse: 
> TResponse);
> begin
>   Application.Terminate;
> end;
>
> procedure ConfigureStandalone;
> begin
>   heaptrc.SetHeapTraceOutput('log.txt');
>   heaptrc.GlobalSkipIfNoLeaks := True;
>   heaptrc.HaltOnError := False;
>   with TIniFile.Create('demo.ini') do
>   try
> Application.Port := ReadInteger('Standalone','Port',8080);
>   finally
> Free;
>   end;
>   HTTPRouter.RegisterRoute('quit', rmAll, @TerminateCallBack, True);
> end;
> {$endif}
>
> begin
> {$ifdef STANDALONE}
>   ConfigureStandalone;
> {$endif}
>   Application.Initialize;
>   Application.Run;
> end.
>
> ===END===
>
> My environment is:  Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64
>
> Best regards,
> Marcos Douglas

Michael,
Would you want that I open a issue for it?

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-06 Thread Marcos Douglas B. Santos
On Sun, May 6, 2018 at 6:26 PM, Marcos Douglas B. Santos <m...@delfire.net> 
wrote:
> On Sun, May 6, 2018 at 6:05 PM, leledumbo via fpc-pascal
> <fpc-pascal@lists.freepascal.org> wrote:
>>> Create a call that calls Application.Terminate.
>>
>> I just call DumpHeap(false); instead
>
> Where is this function or method? Could you give so more information
> how is this works with heaptrc?

I saw that it's part or webutil unit... it is not the case here. But thanks.

> About my test, do you have the same memleak?

Could you please do the same test?

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-06 Thread Marcos Douglas B. Santos
On Sun, May 6, 2018 at 6:05 PM, leledumbo via fpc-pascal
 wrote:
>> Create a call that calls Application.Terminate.
>
> I just call DumpHeap(false); instead

Where is this function or method? Could you give so more information
how is this works with heaptrc?

About my test, do you have the same memleak?

Thanks.

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-06 Thread Marcos Douglas B. Santos
On Sat, May 5, 2018 at 11:51 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Sat, 5 May 2018, Marcos Douglas B. Santos wrote:
>
>> I'm using fpWeb in standalone mode (fphttpapp unit) to develop and debug.
>> I would like to see the heaptrc log in the end, as we can do in normal
>> desktop applications.
>>
>> So, in one route I create an object and don't release it to simulate a
>> memleak.
>>
>> I've tried to set heaptrc.SetHeapTraceOutput('log.txt'). The app
>> creates the file, but there is no log there.
>
>
> This is definitely necessary.
>
>>
>> I've tried to execute using F9 IDE and by command-line too.
>> I think the problem is that we need to kill the server (Ctrl+C) and,
>> because that, no log is created.
>>
>> So, how can I see the log?
>
>
> Create a call that calls Application.Terminate.

Michael,

I believe there is a memleak but I couldn't found.
I've just created a route that calls Application.Terminate and I got this:

===BEGIN===
Heap dump by heaptrc unit
387 memory blocks allocated : 18658/19944
385 memory blocks freed : 18626/19912
2 unfreed memory blocks : 32
True heap size : 196608 (96 used in System startup)
True free heap : 196320
Should be : 196352
Call trace for block $034CA470 size 16
  $0042D3C1
  $00438926
  $004375AA
  $00437268
  $004265FB
  $BAADF00D
  $BAADF00D
  $BAADF00D
Call trace for block $034CA410 size 16
  $0042CE3B
  $0042D3C1
  $00438926
  $004375AA
  $00437268
  $004265FB
  $BAADF00D
  $BAADF00D

===END===


Here is my test program:

===BEGIN===
program demo;

{$define STANDALONE}

uses
  SysUtils,
  httpdefs, httproute,
{$ifdef STANDALONE}
  fphttpapp,
{$endif}
{$ifdef FCGI}
  fpfcgi,
{$endif}
  IniFiles;

{$ifdef STANDALONE}
procedure TerminateCallBack({%H-}ARequest: TRequest; {%H-}AResponse: TResponse);
begin
  Application.Terminate;
end;

procedure ConfigureStandalone;
begin
  heaptrc.SetHeapTraceOutput('log.txt');
  heaptrc.GlobalSkipIfNoLeaks := True;
  heaptrc.HaltOnError := False;
  with TIniFile.Create('demo.ini') do
  try
Application.Port := ReadInteger('Standalone','Port',8080);
  finally
Free;
  end;
  HTTPRouter.RegisterRoute('quit', rmAll, @TerminateCallBack, True);
end;
{$endif}

begin
{$ifdef STANDALONE}
  ConfigureStandalone;
{$endif}
  Application.Initialize;
  Application.Run;
end.

===END===

My environment is:  Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Cross compiling: Win 32 to 64

2018-05-06 Thread Marcos Douglas B. Santos
Sorry guys, I've just forgot to setup in Lazarus, Config and Target this:
 -Twin64   _AND_  -Px86_64 parameters.

In the first time, I just set -Twin32 but -P stayed "(default)":|
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Cross compiling: Win 32 to 64

2018-05-06 Thread Marcos Douglas B. Santos
I have a script for a long time that I use to compile FPC from sources.
Today I'm configuring a new machine and I would like to use this
script to configure FPC and Lazarus — I have another script for
Lazarus as well.

I've compiled FPC with no errors using this script. I use
`crossinstall` too. Again, no errors.

You can see it here (today I changed it a little just to simplify) -->
https://github.com/mdbs99/fp-scripts/blob/master/fpc-make.bat

So, my issue is that:
When I open Lazarus and setup from Win32 to Win64, the IDE says me:
"The current FPC has no config file. It will probably miss some units.
Check your installation of fpc."

After the installation, I can see these directories:
1. /bin/i386-win32
2. /units/i386-win32
3. /units/x86_64-win64

Should I have the same `/bin/x86_64-win64` directory after the compilation?
What am I missing here?

Best,
Marcos Douglas

PS. I know that there are others ways to install, like fpcup|deluxe,
but I would like to use my script because could be just a simple
change that I forgot...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Feature announcement: default namespaces

2018-05-06 Thread Marcos Douglas B. Santos
On Sun, May 6, 2018 at 10:45 AM, Vojtěch Čihák  wrote:
> i,
>
> LCLIntf, LCLProc, LCLType isn't enough? I will use dotted units only if
> there will be absolutely no other way around.

There are many others without LCL prefix...

> I believe it can be useful but I don't think it's "must have" (when I don't
> consider Delphi compat.).

I've said "would..." and "could..."

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

Re: [fpc-pascal] Feature announcement: default namespaces

2018-05-06 Thread Marcos Douglas B. Santos
On Sun, May 6, 2018 at 4:40 AM, Sven Barth via fpc-pascal
 wrote:
> [...]
>
> In FPC we currently don't use dotted unit names much, but maybe that will
> change in the future.

Would be good if all units could be prefixed to make a pattern, like
`fpc.web, fpc.xml, ...` but I know that we need to maintain the
compatibility with Delphi using the same names...
However, Lazarus could do that — we just need a replace in the code.

By the way, good work!

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] fpWeb: How can I use heaptrc in standalone mode?

2018-05-05 Thread Marcos Douglas B. Santos
I'm using fpWeb in standalone mode (fphttpapp unit) to develop and debug.
I would like to see the heaptrc log in the end, as we can do in normal
desktop applications.

So, in one route I create an object and don't release it to simulate a memleak.

I've tried to set heaptrc.SetHeapTraceOutput('log.txt'). The app
creates the file, but there is no log there.

I've tried to execute using F9 IDE and by command-line too.
I think the problem is that we need to kill the server (Ctrl+C) and,
because that, no log is created.

So, how can I see the log?

Lazarus 1.8.3 r57764 FPC 3.0.4 i386-win32-win32/win64

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

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Marcos Douglas B. Santos
On Sun, Mar 11, 2018 at 11:51 AM, Vojtěch Čihák  wrote:
> With this modification and -gh it is alright:
>

Only if you declare `Bar` as `IBar` instead of `TBar`. Please, check
your code again.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Marcos Douglas B. Santos
Not here. I'm using FPC 3.0.4.
I've took a look at EMB documentation:
http://docwiki.embarcadero.com/Libraries/XE2/en/System.SysUtils.Supports
Take a look at "Warning" section. That's the problem.

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

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Marcos Douglas B. Santos
On Sun, Mar 11, 2018 at 11:17 AM, Vojtěch Čihák  wrote:
> Yes, TBar is TInterfacedObject and is reference counted therefore Free is
> not needed.
>
> Just comment the line //Bar.Free; compile with -gh and you will see no
> memory leak.

You think this is the problem...
All right, try to change your copy like this:

===begin===
  Bar := TBar.Create;
  try
if Supports(Bar, IBar) then
  Writeln(Bar.Name + ' supports...');
  finally
Bar.Free;  << no Free
  end;
===end===

Are you still seeing an AV?

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

Re: [fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Marcos Douglas B. Santos
On Sun, Mar 11, 2018 at 10:52 AM, Vojtěch Čihák  wrote:
>
> Hi,
>
> Bar shoud be released by Interface, no need to call Free.

I'm sorry, but `Bar` was defined as `Bar: TBar` so, it's a class not
an interface.

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

[fpc-pascal] Using Supports() I got an AV... bug?

2018-03-11 Thread Marcos Douglas B. Santos
The code below should work but I get an AV when the program calls
`Bar.Free`.

Do you know why?

Lazarus 1.8.1 r57299 FPC 3.0.4 i386-win32-win32/win64

===begin===
program Project1;

uses
  SysUtils;

type
  IBar = interface
  ['{C22FB8F4-1EC6-42C4-81E4-F2A52CC52258}']
function Name: string;
  end;

  TBar = class(TInterfacedObject, IBar)
  public
function Name: string;
  end;

{ TBar }

function TBar.Name: string;
begin
  Result := ClassName;
end;

var
  Bar: TBar;

begin
  Bar := TBar.Create;
  try
if Supports(Bar, IBar) then
  Writeln('Bar supports...');
  finally
Bar.Free;
  end;

end.
===end===

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] AVG says EXE has a virus | FPC 37459 rev

2018-01-22 Thread Marcos Douglas B. Santos
I've also compiled using FPC -> /tags/release_3_0_4 and I had no issues.

Seems a problem only in /branches/fixes_3_0 (after 37459 rev).

Regards,
Marcos Douglas

On Mon, Jan 22, 2018 at 11:37 PM, Marcos Douglas B. Santos <m...@delfire.net>
wrote:

> Hi,
> I've updated my FPC -> /branches/fixes_3_0 from 37459 rev (2017-10-01) to
> 38018 rev (2018-01-10).
> Every time that I'm compiling a project, my AVG antivirus says that
> "Win32:MalOb-IJ [Cryp]" was neutralized.
>
> Lazarus 1.8.1 r57007 FPC 3.0.3 i386-win32-win32/win64
>
> This not occur if I compile using FPC 37459 rev.
>
> I already scanned all my computer, starting in FPC/Lazarus directories but
> AVG didn't found anything. The problem is just when I'm compiling.
>
> Thoughts?
>
> Best regards,
> Marcos Douglas
>
>
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] AVG says EXE has a virus | FPC 37459 rev

2018-01-22 Thread Marcos Douglas B. Santos
Hi,
I've updated my FPC -> /branches/fixes_3_0 from 37459 rev (2017-10-01) to
38018 rev (2018-01-10).
Every time that I'm compiling a project, my AVG antivirus says that
"Win32:MalOb-IJ [Cryp]" was neutralized.

Lazarus 1.8.1 r57007 FPC 3.0.3 i386-win32-win32/win64

This not occur if I compile using FPC 37459 rev.

I already scanned all my computer, starting in FPC/Lazarus directories but
AVG didn't found anything. The problem is just when I'm compiling.

Thoughts?

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Final Methods support

2018-01-06 Thread Marcos Douglas B. Santos
On Sat, Jan 6, 2018 at 2:41 PM, Sven Barth via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
> Am 06.01.2018 17:31 schrieb "Marcos Douglas B. Santos" <m...@delfire.net>:
>
> Does FPC have support for final methods?
>
> Please see ->
> http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Methods_(Delphi)#Final_Methods
>
>
> Should be supported since 2009, so that would be from at least 2.6.0.

Ok, thanks!

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Final Methods support

2018-01-06 Thread Marcos Douglas B. Santos
Does FPC have support for final methods?

Please see ->
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Methods_(Delphi)#Final_Methods

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] CGI/FastCGI and WS request with a max time response

2018-01-04 Thread Marcos Douglas B. Santos
On Thu, Jan 4, 2018 at 10:33 PM, leledumbo via fpc-pascal
 wrote:
>> The problem is that the WS could take so long time that the entire request
> will broke with a "time out".
>
> I suggest making the request handling asynchronous instead. So request will
> only register and return some unique id to the requester, then do call to
> the WS in background thread. An endpoint shall be provided that when given a
> unique id will check whether the corresponding thread has finished executing
> or not, returning 200 + response data when done, and 202 if still in
> progress. This endpoint shall be called in regular interval by the
> requester, until it finishes processing or your server dies (500).

Interesting, but I can't do this way.
It should be just one call from client (desktop app and website) to my
REST service.
My service encapsulates the WS.
As I wrote previously to Michael, if the WS do not respond in "X
seconds", my service should forget it and return a "code Y".

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] CGI/FastCGI and WS request with a max time response

2018-01-04 Thread Marcos Douglas B. Santos
On Thu, Jan 4, 2018 at 6:33 PM, Michael Van Canneyt
 wrote:
>
> If you use a thread to consume it, yes.
>
> Without more info on how you consume this webservice, it's difficult to
> answer this.

Yes, sorry. I should explained more.
I'm using WST -> http://svn.code.sf.net/p/lazarus-ccr/svn/wst (rev.
5836) to consume WS.
Until now, I didn't find how to set a timeout in WST objects — is this possible?
As you already said, I thought to use a thread, but I may need to
control this manually... ideas how to do this as simple as possible?

My requirement is: If WS do not respond in "X seconds", forget it and
return the "code Y".

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] CGI/FastCGI and WS request with a max time response

2018-01-04 Thread Marcos Douglas B. Santos
Hi,

I have a FastCGI application which needs to receive an user request but, in
some cases, the app should consume a WebService(WS) before make the
response to the user.
The problem is that the WS could take so long time that the entire request
will broke with a "time out".

My question is: Can I consume this WS with a max time to wait?
Would be better doing this in the code instead of change parameters in the
webserver. But, if there is no (simple) way to do that in the code, the
webserver more used to this app is Microsoft IIS.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc2js

2017-12-06 Thread Marcos Douglas B. Santos
On Wed, Dec 6, 2017 at 9:48 AM, Victor Campillo
 wrote:
> Hi,
>
> Testing the preview that Michael was so kind to share, I found the next
> minor problems trying to compile the packages included, I think that
> everything is related to that the project is work in progress so nothing to
> worry much about.
>
>  * Package fcl_base
>  o The package is configured as "designtime and runtime" and this
>cause that the IDE complains about missing register procedure if
>you try to install.
>  o Inside the folder fcl-base there is a unit called "browserapp"
>that is not used in the package which could be correct but I
>mention it just in case you forgot to include it in the package.
>  o It does not include the command to call pas2js compiler.
>  o Adding the command to call pas2js and changing the package to
>runtime just compile fine.
>  * Package fcl-db
>  o The package include the unit "restconnection" which is missing.
>  o Just removing restconnection, the package compile without problems.
>  * Package fpcunit
>  o The package include the unit "htmltestreport" which is missing.
>  o The package is configured as "designtime and runtime" and this
>cause that the IDE complains about missing register procedure if
>you try to install.
>  o It does not include the command to call pas2js compiler.
>  o Solving the previous remarks, the compilation fails with the message
> "plaintestreport.pas(166,6) Error: identifier not found "IRound""
>
>
> I will try to convert a little JavaScript project I have to pascal and use
> pas2js, I will let you know if I found any problems do it.

Thank you that work!

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC 3.0.4 released!

2017-12-06 Thread Marcos Douglas B. Santos
On Tue, Dec 5, 2017 at 10:13 PM, Graeme Geldenhuys
 wrote:
>
> Windows just isn't fun. Long live FreeBSD and Linux.

I believe you compile FPC on Linux, right?
So, why do you do the same on Windows? It's pretty easy...

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC attributes / annotations support

2017-12-01 Thread Marcos Douglas B. Santos
On Thu, Nov 30, 2017 at 5:35 PM, Graeme Geldenhuys
<mailingli...@geldenhuys.co.uk> wrote:
> On 2017-11-29 23:37, Marcos Douglas B. Santos wrote:
>
>> "No one are using Object Pascal nowadays".
>
>
> It seems there is still pretty good interest in Object Pascal in Brazil. We
> have a 21 year old that just got hired, and he studied Object Pascal in
> Brazil. I found such a "young age Object Pascal developer" rather
> surprising, because everybody else I've met that does Delphi/Object Pascal
> coding has been much older. The 90's generation that grew up. :)

Yes, there is still pretty good interest in Object Pascal in Brazil —
I have been
writing in a blog[1] for 2 years and it still growing — but it's not
like it used to be in
Delphi 5~7 many years ago.

>> I hear something like this two times per month.  :\
>
> We have a recruitment agent that sends any Object Pascal developer he finds
> to us - if we are actively looking or not. If they are skilled, we find a
> role for them - and that keeps our dev teams topped up.

Very good.

>> If we have a better marketing, maybe more programmers could have more
>> interest to use the language.
>
> Yeah, if the FPC Foundation could help with marketing the language and FPC
> (and Lazarus), that would be a great step in the right direction.

I agree.

Best regards,
Marcos Douglas

[1] https://goo.gl/ROmyBb
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC attributes / annotations support

2017-11-30 Thread Marcos Douglas B. Santos
On Thu, Nov 30, 2017 at 4:23 AM, LacaK  wrote:
>
>>> the idea) a rewrite of a multi-million lines of code project into C#,
>>> rather
>>> than move to open source development tools where they can keep the huge
>>> code
>>> base, the same language and reuse the same development skills. How
>>> weird??
>>> Have corporates lost their minds.
>>
>> I believe that the real problem is to find Object Pascal programmers
>> comparing with other languages.
>> The companies are thinking in their future.
>>
>> "Who will maintain this code?"
>> "No one are using Object Pascal nowadays".
>>
>> I hear something like this two times per month.  :\
>>
>> However, we know the potential of Object Pascal as a language to do
>> anything.
>> If we have a better marketing, maybe more programmers could have more
>> interest to use the language.
>
> IMO root of problem is in schools. People come to companies from schools and
> what they have learned in schools, is what they are expecting in companies
> ...
> When I walked to school, we learned Pascal, I am suspicious, that this does
> not happen nowadays.

Yes.
And I think people are thinking in Object Pascal as Turbo Pascal or
something like that.
I believe most don't know about FPC as a modern compiler.
Is so simpler using Object Pascal environment than Java or .NET. So,
FPC could be more used by schools.

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] MSEide+MSEgui 4.6 for FPC 3.0.4

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 9:35 PM, Rainer Stratmann
 wrote:
> Am Mittwoch, 29. November 2017, 07:19:32 schrieb Martin Schreiber:
>> What is missing
>> in Free Pascal?
>
> A userfriendly setup/install for every compile/cross compile scenario out of
> the box.
>
> Without the need for compiling fpc.
>
> Without the need for an internet connection.

Have you already seen fpcup -> http://wiki.freepascal.org/fpcup ?

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] MSEide+MSEgui 4.6 for FPC 3.0.4

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 9:26 PM, Graeme Geldenhuys
 wrote:
> On 2017-11-29 06:19, Martin Schreiber wrote:
>>
>> What is missing in
>> Free Pascal?
>
>
> Good question. After all, Delphi used the FPC compiler to develop for iOS
> before they had their own compiler ready. I believe XE2 shipped with a FPC
> compiler. So FPC functionality (the compiler at least) must have enough to
> make it usable.

We have the compiler, now it just missing the widgets...

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC attributes / annotations support

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 8:55 PM, Graeme Geldenhuys
 wrote:
>
> Yup, I gathered that much... Hence the "dreaming" tag I used. :)
>
> I just can't believe how bad things have become in Delphi. A commercial
> "professional" and "enterprise" quality product - it's everything but that!
> And the asking price is higher than it has ever been before. Amazing what a
> strong hold Embarcadero has with their "ransome-ware pricing model" on
> corporate companies. The open source alternatives are simply miles ahead -
> but corporates are reluctant to budge. Instead they will consider (toy with
> the idea) a rewrite of a multi-million lines of code project into C#, rather
> than move to open source development tools where they can keep the huge code
> base, the same language and reuse the same development skills. How weird??
> Have corporates lost their minds.

I believe that the real problem is to find Object Pascal programmers
comparing with other languages.
The companies are thinking in their future.

"Who will maintain this code?"
"No one are using Object Pascal nowadays".

I hear something like this two times per month.  :\

However, we know the potential of Object Pascal as a language to do anything.
If we have a better marketing, maybe more programmers could have more
interest to use the language.

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC attributes / annotations support

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 11:31 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Wed, 29 Nov 2017, Marcos Douglas B. Santos wrote:
>
>> On Wed, Nov 29, 2017 at 11:10 AM, Michael Van Canneyt
>> <mich...@freepascal.org> wrote:
>>>
>>>
>>> I do. I meant that I use pas2js as the precompiler command.
>>
>>
>> Hmm... right.
>> I saw yesterday, in the official website, that FPC 3.0.4 was released
>> but I didn't see an email about it...
>> Is pas2js included in that version?
>
>
> No, but I plan to make pas2js generally available this weekend.

OK, thank you.


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

Re: [fpc-pascal] FPC attributes / annotations support

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 11:10 AM, Michael Van Canneyt
 wrote:
>
> I do. I meant that I use pas2js as the precompiler command.

Hmm... right.
I saw yesterday, in the official website, that FPC 3.0.4 was released
but I didn't see an email about it...
Is pas2js included in that version?

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC attributes / annotations support

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 6:39 AM, Michael Van Canneyt
 wrote:
>
>
> On Wed, 29 Nov 2017, Graeme Geldenhuys wrote:
>
>> On 2017-11-27 21:39, Mattias Gaertner wrote:
>>>
>>> Lazarus now supports attributes.
>>
>>
>> Awesome, thanks for the update.
>>
>> [dreaming]
>> Now only if Lazarus could support the Delphi dcc32 compiler. ;-) Boy oh
>> boy... I've been using Delphi XE3 for a month now (new job) - it is SH*T.
>> Constant IDE crashes, online help doesn't work, the bug reporting dialog
>> that pops up after a IDE crash doesn't work (the irony), code syntax check
>> is broken, can't customise the shortcuts etc. I so miss Lazarus and FPC!
>> [/dreaming]
>
>
> You can. In the project options, set the Pre-compiler command to DCC32.
> Uncheck the compile step.
>
> This is how we compile web projects currently.

What? I thought that you use FPC for web projects...

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC attributes / annotations support

2017-11-29 Thread Marcos Douglas B. Santos
On Wed, Nov 29, 2017 at 4:50 AM, Graeme Geldenhuys
 wrote:
>
> [dreaming]
> Now only if Lazarus could support the Delphi dcc32 compiler. ;-) Boy oh
> boy... I've been using Delphi XE3 for a month now (new job) - it is SH*T.
> Constant IDE crashes, online help doesn't work, the bug reporting dialog
> that pops up after a IDE crash doesn't work (the irony), code syntax check
> is broken, can't customise the shortcuts etc. I so miss Lazarus and FPC!
> [/dreaming]

Even if Lazarus could support Delphi dcc32, would not be enough
because it will still missing the components.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] MSEide+MSEgui 4.6 for FPC 3.0.4

2017-11-25 Thread Marcos Douglas B. Santos
Em 25 de nov de 2017 2:43 PM, "Martin Schreiber" 
escreveu:


And why Free Pascal to develop the android application?


For the same reasons that we use Object Pascal instead of C# , Java,
whatever.

Best,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Memory Leak's in XMLRead unit

2017-11-08 Thread Marcos Douglas B. Santos
On Wed, Nov 8, 2017 at 10:52 AM, African Wild Dog
 wrote:
> 2017-11-07 23:57 GMT-02:00 Michael Van Canneyt :
>>
>> ...
>>
> My environment: Linux Debian Stretch 64 bits - Lazarus 1.6.4 - fpc 3.0.2.
>
> I'm quite impressed with the processing power of fastcgi fcl-web
> applications: they consume little memory (less than 2 MB per instance) and
> are very fast to process the requests.

It is fast even on Windows+IIS.  ;)

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic compiler error

2017-10-23 Thread Marcos Douglas B. Santos
On Mon, Oct 23, 2017 at 6:50 AM, Sven Barth via fpc-pascal
 wrote:
> Am 23.10.2017 08:29 schrieb "Marco van de Voort" :
>
> In our previous episode, Sven Barth via fpc-pascal said:
>>
>> Type aliases are currently not supported in mode Delphi. In mode ObjFPC
>> they might work, but I'm not sure about that either...
>>
>> That said I also don't see the use of type aliases for generics...
>
> How about a simple
>
>
> type   = anotherunit.;
>
> ?
>
> That is often what I use type aliases for, aliasing code that has been
> factored out of an unit back in.
>
>
> Okay, that's an acceptable use case ^^'

So, can we have this in the next version?  :)

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic compiler error

2017-10-23 Thread Marcos Douglas B. Santos
On Sun, Oct 22, 2017 at 11:53 PM, Ryan Joseph
<r...@thealchemistguild.com> wrote:
>
>
>> On Oct 23, 2017, at 9:14 AM, Marcos Douglas B. Santos <m...@delfire.net> 
>> wrote:
>>
>> How do the same with generic classes, using mode delphi?
>
> I think you need to specialize then alias the specialize type. Why do you 
> want to make an alias for an untyped generic anyways?

As Marco showed, to do this:

type   = anotherunit.;

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic compiler error

2017-10-23 Thread Marcos Douglas B. Santos
On Mon, Oct 23, 2017 at 3:28 AM, Marco van de Voort  wrote:
> In our previous episode, Sven Barth via fpc-pascal said:
>>
>> Type aliases are currently not supported in mode Delphi. In mode ObjFPC
>> they might work, but I'm not sure about that either...
>>
>> That said I also don't see the use of type aliases for generics...
>
> How about a simple
>
>
> type   = anotherunit.;
>
> ?
>
> That is often what I use type aliases for, aliasing code that has been
> factored out of an unit back in.

+1
That is I am talking about. Thanks.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Generic compiler error

2017-10-22 Thread Marcos Douglas B. Santos
Hi,

In Pascal we can do this:

type
  TXStream = TStream;

Now, TXStream is just an alias to TStream.

How do the same with generic classes, using mode delphi?

  TBar = TFoo;

Compile Project, Target: C:\temp\project1.exe: Exit code 1, Errors: 4
project1.lpr(25,18) Error: Identifier not found "T"
project1.lpr(25,19) Error: Type identifier expected
project1.lpr(25,20) Error: Error in type definition
project1.lpr(27,1) Error: This type cannot be a generic

My ENV is:
Lazarus 1.9.0 r56056M
FPC 3.1.1 r37505
i386-win32-win32/win64


Please, see an example below:

=== BEGIN ===

program Project1;

{$mode delphi}

uses
  Classes;

type
  IFoo = interface
  ['{5CA4AEC4-3875-4639-9975-AC2C201E0A98}']
function Value: T;
  end;

  TFoo = class(TInterfacedObject, IFoo)
  private
FValue: T;
  public
constructor Create(Value: T);
class function New(Value: T): IFoo;
function Value: T;
  end;

  TXStream = TStream;  //  OK

  TBar = TFoo; //  how solve this?

constructor TFoo.Create(Value: T);
begin
  inherited Create;
  FValue := Value;
end;

class function TFoo.New(Value: T): IFoo;
begin
  Result := Create(Value);
end;

function TFoo.Value: T;
begin
  Result := FValue;
end;

begin
  Writeln(TFoo.New(1).Value);
  Readln;
end.

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

Re: [fpc-pascal] Lua language in /packages/lua will be update?

2017-10-15 Thread Marcos Douglas B. Santos
On Sun, Oct 15, 2017 at 1:27 PM, Ryan Joseph  wrote:
> here’s the version I found which I’m using. It’s 5.3 so it’s more recent at 
> least.
>
> https://github.com/malcome/Lua4Lazarus/blob/master/lua53.pas

Thanks...
But the problem with this project is that it is not updated since 3 years.
My concern is to use something that is no longer updated.

Would be better if the original author, who made this version, update
the sources.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Lua language in /packages/lua will be update?

2017-10-15 Thread Marcos Douglas B. Santos
Hi,

I would like to know if the translation of Lua to FPC, which I found
in /packages/lua, is an official translation or just a lib made by
someone else, which was included in packages.

I am asking because the last release of Lua is 5.3.4 (Jan/2017) and
the FPC code is using the 5.1 version which was released in Feb/2006.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] JavaScript versions of pascal RTL functions (FormatFloat, DateToStr etc)

2017-10-15 Thread Marcos Douglas B. Santos
On Sun, Oct 15, 2017 at 8:25 AM, Michael Van Canneyt
 wrote:
>
>
> Hello,
>
> If you want the latest preview and demos to play with:
>
> https://www.freepascal.org/~michael/pas2js-demo-0.8.28.zip
>
> The component developer is doing fantastic work with the visual components,
> and it starts to look really good.

Looks a huge work!
Thanks for that preview.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Google Drive API

2017-10-14 Thread Marcos Douglas B. Santos
On Sat, Oct 14, 2017 at 1:01 AM, leledumbo via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
> Marcos Douglas B. Santos wrote
>> I didn't found...  In this path \packages\googleapi\examples only
>> exists \generator directory.  :(
>>
>> Trunk, rev 37453.
>
> Try this, it wasn't running well due to RTTI changes back then, but probably
> works now:
> http://free-pascal-general.1045716.n5.nabble.com/ERESTAPI-TBuckets-unsupported-array-element-type-lt-looks-like-empty-string-gt-td5726387.html
>

OK, thanks.
I found an example in Lazarus directory too, but I haven't tested yet.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Google Drive API

2017-10-13 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 10:17 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
>
> On Wed, 11 Oct 2017, Marcos Douglas B. Santos wrote:
>
>> Hi,
>>
>> I would like to know if FPC implements the full Google Drive API. If
>> so, since which version?
>
>
> Yes, since version 3.0.2.
>
> FPC also contains a tool to generate a new API if google changes it
> (they have a lot of APIS, which get updated on a regular basis)
>
>> First, I need to implement upload, download and search of files [1].
>> Any example?
>
>
> Yes. See the googleapi source dir in trunk, examples/drive

Hi Michael, sorry my late.
I didn't found...  In this path \packages\googleapi\examples only
exists \generator directory.  :(

Trunk, rev 37453.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Const params question

2017-10-11 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 9:33 AM,   wrote:
> On 11/10/17 13:11, Michael Van Canneyt wrote:
>>
>> Delphi has recently
>
>
> Huh? I thought Delphi got shut down years ago.

See https://www.embarcadero.com/products/delphi


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

[fpc-pascal] Google Drive API

2017-10-11 Thread Marcos Douglas B. Santos
Hi,

I would like to know if FPC implements the full Google Drive API. If
so, since which version?
First, I need to implement upload, download and search of files [1].
Any example?

[1] https://developers.google.com/drive/v3/web/manage-uploads

Thanks,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Const params question

2017-10-11 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 9:11 AM, Michael Van Canneyt
<mich...@freepascal.org> wrote:
>
> On Wed, 11 Oct 2017, Marcos Douglas B. Santos wrote:
>
> [...]
>> Is constref compatible with Delphi?
>
>
> Delphi has recently introduced some annotation for the same purpose.
>
> As usual, they chose to do something different than what FPC did.

Hmm, OK. Thanks.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Const params question

2017-10-11 Thread Marcos Douglas B. Santos
On Wed, Oct 11, 2017 at 7:01 AM, Michael Van Canneyt
 wrote:
>
>
> On Wed, 11 Oct 2017, Ryan Joseph wrote:
>
>> If you declare a parameter as const does that effectively behave like
>> passing by reference?  I have some performance sensitive functions that
>> take records as arguments and I don’t want copying to the stack so I’ve
>> been using @ but maybe const is just as good?  Thanks.
>
>
> No, you need constref then.

Is constref compatible with Delphi?

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Managed properties idea

2017-10-09 Thread Marcos Douglas B. Santos
On Mon, Oct 9, 2017 at 3:54 PM, Maciej Izak <hnb.c...@gmail.com> wrote:
> 2017-10-09 14:43 GMT+02:00 Marcos Douglas B. Santos <m...@delfire.net>:
>>
>> This TAutoFree just "put" the "finally" and call .Free for an array of
>> objects or does it something else?
>> Could you send the link of the implementation?
>
>
> "One" and "Several" returns IAutoFree interface. Implementation of that
> interface contains TObject/array of TObject fields.  TObject/array of
> TObject is freed when interface goes out of the scope (so yes you can omit
> "finally", the "Free" call for allocated objects by TAutoFree is
> guaranteed). Documentation:
>
> https://synopse.info/files/html/api-1.18/SynCommons.html#TAUTOFREE
> https://synopse.info/files/html/Synopse%20mORMot%20Framework%20SAD%201.18.html#TITL_130

Hmm, smart. Thanks for that.

> please note that FPC behaves different than Delphi, so you can't do the
> Delphi trick:
>
> ===code begin===
> var
>   o: TFoo;
> begin
>   TAutoFree.One(o, TFoo.Create); // for such code interface is released at
> this place in FPC
>   WriteLn(o.SomeMethod); // AV i FPC
> end; // in Delphi returned interface by TAutoFree.One is released here
> ===code end===
>
> so correct code for FPC is:
>
> ===code begin===
> var
>   o: TFoo;
> begin
>   with TAutoFree.One(o, TFoo.Create) do
>   begin
> WriteLn(o.SomeMethod);
> o.SomeProperty := 123;
>   end;
> end;
> ===code end===
>
> Maybe at some point the first code listing will be valid in FPC too (by
> usage of new modeswitch SCOPEDINTERFACEDESTROY).

IMHO, FPC implementation is more correct because the scope really finished.
Using `with` is elegant too.

> implementation of TAutoFree can be found here:
>
> https://github.com/synopse/mORMot/blob/master/SynCommons.pas

I saw, thank you again.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Managed properties idea

2017-10-09 Thread Marcos Douglas B. Santos
On Mon, Oct 9, 2017 at 5:24 AM, Maciej Izak  wrote:
> 2017-10-07 2:10 GMT+02:00 Michalis Kamburelis :
>>
>> [...]
>
> mORMot framework has also nice solution for "auto free" (solution uses
> interfaces too):
>
> ===code begin===
>   with TAutoFree.One(o, TObject.Create) do
>   begin
> ...
> Another(o2, TObject.Create);
> ...
>   end;
>
>   with TAutoFree.Several([
> o, TObject.Create,
> f, TFoo.Create,
> sl, TStringList.Create])
>   do
>   begin
> ...
>   end;
> ===code end===
>
> somehow similar in usage like "using" from C#

This TAutoFree just "put" the "finally" and call .Free for an array of
objects or does it something else?
Could you send the link of the implementation?

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Managed properties idea

2017-10-07 Thread Marcos Douglas B. Santos
On Fri, Oct 6, 2017 at 4:49 PM, Michalis Kamburelis
<michalis.ka...@gmail.com> wrote:
> 2017-10-06 20:52 GMT+02:00 Marcos Douglas B. Santos <m...@delfire.net>:
> [...]
>>> In this case, in which you indeed want two of these features simultaneously,
>>> I advise COM interfaces myself :) That's why they are documented after all.
>>
>> I can use it only to use reference counting.
>
> You can, but it's a little uncomfortable.
>
> If you use interfaces only for reference counting (not to share the
> API between some unrelated classes), then you define a single
> interface for each single class, repeating the same API -- methods,
> properties. It's possible, but it's just a lot of work. I have a lot
> of classes in my engine, and FPC RTL, FCL, Lazarus LCL define many
> more classes --- wrapping them all in an equivalent interface, only to
> get reference-counting for them, would imply a lot of work and
> constant maintenance.

I use interfaces because, IMO, this is the right way to write
object-oriented code.
First you start with the interface that will be the contract. Then,
you create one or more classes "to give life" an object which
represents a real entity. Finally, every method argument or class
attribute, should be an interface-type variable — most cases.
The repetition here is due to the language design, but I'm OK with it.
Sometimes you may have 1:1 (1 interface, 1 class) but you can have
1:N.
You (or just me) don't need to create an interface with the same
methods/properties to use FPC RTL, FCL, Lazarus LCL just to wrap them
to use reference-counting. This might be wrong at most cases. That is
code duplication.
We already have this infrastructure in FPC RTL, FCL, Lazarus LCL — not
perfect, but... — and we don't need to recreate them in our business,
we just use them. So, for example, if I need to open a file, I will
have an interface that represents a file in my business and then I
will use a TFileStream class encapsulated in my own representation
(class) of my interfaced.

Most cases we don't need the dozens methods which many classes have —
even in Java or C# do that.

> In contrast, something like C++ "shared pointer" is a feature that can
> be applied to any existing class, without the need to repeat it's API.
> See e.g. https://en.wikipedia.org/wiki/Smart_pointer . And once we
> have management operators (see Sven's pointers), we can implement
> something like this in Pascal. So you could use something like
> "TSharedPointer" and you get a reference-counted instance
> of TStringList.

OK, it sounds interested but would be a better design if a
"modeswitch" turn on this as default for entire unit, ie, every
instance will be reference-counted.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Managed properties idea

2017-10-07 Thread Marcos Douglas B. Santos
On Fri, Oct 6, 2017 at 4:17 PM, Sven Barth via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
> Am 06.10.2017 20:52 schrieb "Marcos Douglas B. Santos" <m...@delfire.net>:
>> > And reference counting like in e.g. C++ "shared  pointers", that can
>> > wrap any
>> > class, without any additional feature (in Pascal we may get this with
>> > "management operators").
>>
>> I don't know about "management operators". Could you explain more about
>> them?
>
> Operators for records that are called when initializing, finalizing and
> copying that record. See $fpcdir/tests/test/tmoperator[1-10].pp

I saw... Looks like that now a record is a hybrid made by a record plus a class.
Thanks for the info.

Regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Managed properties idea

2017-10-06 Thread Marcos Douglas B. Santos
On Fri, Oct 6, 2017 at 1:06 PM, Michalis Kamburelis
<michalis.ka...@gmail.com> wrote:
>
> 05.10.2017 2:07 PM "Marcos Douglas B. Santos" <m...@delfire.net> napisał(a):
>
> [...]
> As Sven told you, just use COM Interfaces.
> Look this explanation ->
> http://castle-engine.io/modern_pascal_introduction.html#_corba_and_com_types_of_interfaces
> but don't pay attention when to author says "Ugly (COM) interfaces"
> because it is not. :)
>
> Really, it is not.
>
>
> I hope I explained there why I consider the COM design "ugly": because it
> puts three often-unrelated features (reference counting, and ability for
> multiple classes to expose same API safely, and interaction with COM
> technology) in one bag.

I think you did, but I believe that we can forget the interaction with
COM even that feature was made to work with COM.
IMO, more important is the reference counting.

> In this case, in which you indeed want two of these features simultaneously,
> I advise COM interfaces myself :) That's why they are documented after all.

I can use it only to use reference counting.

> In general, I would prefer these features to be available separately. Like
> other languages do: interfaces in Java and C# are only to "expose same API
> from multiple classes" (granted, comparison is unjust as Java and C# just
> have garbage collection) -- in Pascal you get this by CORBA interfaces.

It would be better if these features were available separately, I agree.
About the gargabe collection, we can use the referece counting for the
same purpose — of course you know this, but maybe we have different
opinions about how to use this feature.

I would agree that "CORBA" interfaces is more pascalish than "COM"
interfaces, but I am sure that reference counting is a good feature to
improve the code design.

> And reference counting like in e.g. C++ "shared  pointers", that can wrap any
> class, without any additional feature (in Pascal we may get this with
> "management operators").

I don't know about "management operators". Could you explain more about them?

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Managed properties idea

2017-10-05 Thread Marcos Douglas B. Santos
On Thu, Oct 5, 2017 at 5:55 AM, Ryan Joseph  wrote:
>
>> On Oct 5, 2017, at 12:28 PM, Sven Barth via fpc-pascal 
>>  wrote:
>>
>> The way to go in Object Pascal are reference counted interfaces (aka 
>> COM-style interfaces). After all one should program against an interface 
>> anyway and that reference counted interfaces are automatically handled by 
>> the compiler is an added bonus.
>>
>>
>
> example? I’ve been doing retain management manually and honestly I prefer 
> that for some cases where I want more control so I still like that syntax 
> option.
>

As Sven told you, just use COM Interfaces.
Look this explanation ->
http://castle-engine.io/modern_pascal_introduction.html#_corba_and_com_types_of_interfaces
but don't pay attention when to author says "Ugly (COM) interfaces"
because it is not. :)

Really, it is not.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FCL-WEB and PostgreSQL Support: Current Status

2017-09-27 Thread Marcos Douglas B. Santos
On Wed, Sep 27, 2017 at 12:16 PM, African Wild Dog
 wrote:
> Hello,
>
> I am about to start a new project for a very small web application.
>
> I have some questions:
>
> 1 - Are the fcl-web and postgres packages stable?
> 2 - Are they recommended for use in production environments?
> 3 - Do they have any serious bug (for example, memory leaks)?

I have been using fcl-web in production about 2 years.
However, my environment is Windows and Microsoft IIS, running FastCGI.
Most of these apps are used to provide REST API's.
I don't have any problems. These apps are fast and I can use shared
code between Desktop and Web. Very good.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Where and Why is there a memory leak?

2017-09-06 Thread Marcos Douglas B. Santos
On Wed, Sep 6, 2017 at 10:17 PM, Ryan Joseph  wrote:
>
>> On Sep 6, 2017, at 10:20 PM, Sven Barth via fpc-pascal 
>>  wrote:
>>
>> You're missing that FHook was declared as IHook, not THook.
>>
>
> In terms of memory why does it matter how it was declared? The memory was 
> allocated in Create() so the declaration is just relevant for the assignment 
> of the new memory. Is FPC doing something magic behind the scenes?
>

Because COM interface variables are automatically released.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Where and Why is there a memory leak?

2017-09-06 Thread Marcos Douglas B. Santos
On Wed, Sep 6, 2017 at 6:55 AM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:

>
> I can't remember ever [while using Delphi] being forced to implement a
> getter method in the "property ... implements..." line, but it seems that
> is the only way it remove memory leaks under FPC. Weird. :-/


You don't need this getter. You have resolved just by change FHookInstance
as a class, not an Interface, plus using TAggregatedObject too.

I wrote an article about it
http://objectpascalprogramming.com/posts/interfaces-delegacao-problemas-solucoes/

(use Google Translator).

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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
<fpc-pascal@lists.freepascal.org> 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
>> something?
>
> It doesn't need to. A type helper is essentially syntactic sugar for a
> class method with the extended parameter as first type.

So, is this work?

=== code begin ===

type
  IFoo = interface
function Execute: IFoo;
  end;

  TFooHelper = type helper for IFoo
procedure Something;
  end;

  TFoo = class(TInterfacedObject, IFoo)
  public
function Execute: IFoo;
  end;

var
  F: IFoo;
begin
  F := TFoo.Create;
  F.Execute.Something;
end;

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

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 declaring the type helper in some other unit.
> B) No other unit you're using also defines a type helper for that same type.
> Only one type helper per type allowed.
>
> 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;
>
> procedure IShellLinkHelper.Save(const Target, Description, Link: string);
> var
>   P: IPersistsFile;
> begin
>   SetPath(Target);
>   SetDescription(Description);
>   if Self is IPersistsFile then
>   begin
> P := Self as IPersistsFile;
> P.Save(Link, True);
>   end;
> end;

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 in Java(?) that we have code inside an interface...


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

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
<fpc-pascal@lists.freepascal.org> wrote:
> Am 23.08.2017 16:58 schrieb "Marcos Douglas B. Santos" <m...@delfire.net>:
>>
>> Is this compatible with Delphi?
>
> Interface helpers are only supported by FPC. But the other helpers (class,
> record, primitive types) are Delphi compatible.

Alright, thanks for the info.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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 know that helpers could be used in enums too. Great.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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 unit declaring the type helper in some other unit.
> B) No other unit you're using also defines a type helper for that same type.
> Only one type helper per type allowed.
>
> 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;

Anthony,

I understood. In fact, this is a great feature for whose work with
interfaces a lot.
We can have small interfaces but add some methods in just some places,
extending such interfaces.

Is this compatible with Delphi?

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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 string,
> but more often than not I need a combination of both results. The previous
> solution would have been a global function, now I can also do a helper with
> a method.

If I understood right, I could have a Interface with 1 method and
maybe 3 classes that implements this method. But one of theses classes
could use an interface helper to add 1 or more methods. All instances
(variables) will be interface-typed but in that last case, the
instance will have more that 1 original method.

Am I right?
(please say yes)

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

  1   2   >