Re: [fpc-pascal] Code tools search paths

2020-05-11 Thread Ryan Joseph via fpc-pascal


> On May 11, 2020, at 6:41 PM, Mattias Gaertner via fpc-pascal 
>  wrote:
> 
> This creates a node for directory Path. Path should be your program
> directory.
> 
> 
>>  UnitPathTemplate := TDefineTemplate.Create('???','???',
>>UnitPathMacroName,
>>UnitPathMacro+';'+ExpandFileName(Path),
>>da_Define
>>);
>>  DirectoryTemplate.AddChild(UnitPathTemplate);
> 
> This expands the UnitPath of directory Path with Path. 
> Maybe you meant
> UnitPathMacro+';'+ExpandFileName(SomeUnitPath),

I wanted this to behave like the compiler normally does, that is you supply 
paths to the units with -Fu and includes with -Fi. What is the way to achieve 
that here?

For example in my test project I have the directory that contains the program 
and another direction to test units in other directories so I basically just 
want:

pp /path/to/test.pas -Fu/path/to/other_units

Pretty simple but I don't seem to be going about it correctly.

Regards,
Ryan Joseph

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


Re: [fpc-pascal] Code tools search paths

2020-05-11 Thread Mattias Gaertner via fpc-pascal
On Mon, 11 May 2020 16:58:54 +0700
Ryan Joseph via fpc-pascal  wrote:

>[...]
> If I just want to add unit search paths do I do this? The user is
> just going to supply absolute paths to the language server (just like
> they would from the command line).

FPC is happy with ppu files. Codetools need sources. So it needs the
settings where the ppu files are coming from. Therefore codetools
allows to have different settings for each directory.


> // add all the unit paths
> for Path in Paths do
> begin
>   DirectoryTemplate :=
> TDefineTemplate.Create('Directory','','',ExpandFileName(Path),da_Directory);

This creates a node for directory Path. Path should be your program
directory.

 
>   UnitPathTemplate := TDefineTemplate.Create('???','???',
> UnitPathMacroName,
> UnitPathMacro+';'+ExpandFileName(Path),
> da_Define
> );
>   DirectoryTemplate.AddChild(UnitPathTemplate);

This expands the UnitPath of directory Path with Path. 
Maybe you meant
UnitPathMacro+';'+ExpandFileName(SomeUnitPath),
?
 
>   CodeToolBoss.DefineTree.Add(DirectoryTemplate);
> end;


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


Re: [fpc-pascal] Compiler mode for code in rtl and rtl-extra

2020-05-11 Thread Bart via fpc-pascal
On Mon, May 11, 2020 at 9:30 AM Michael Van Canneyt
 wrote:

> You are correct. The unit is compiled in fpc mode, which means no "result"
> variable, no out param (replace with var).
>
> We can envision changing this mode, but then the whole unit needs to be
> verified and checked for correct functioning,

Maybe one could apply {$modeswitch out} ?


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


Re: [fpc-pascal] Code tools search paths

2020-05-11 Thread Ryan Joseph via fpc-pascal


> On May 11, 2020, at 4:55 PM, Mattias Gaertner via fpc-pascal 
>  wrote:
> 
> Yes, you can.
> They are treated like global options, i.e. as if added to the fpc.cfg.

Then I don't understand why those affect FindReferences but worked for other 
areas. Using those were easier than what I'm doing with the define templates 
but maybe I'm confused (see my follow up I just sent).

Regards,
Ryan Joseph

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


Re: [fpc-pascal] Code tools search paths

2020-05-11 Thread Ryan Joseph via fpc-pascal


> On May 11, 2020, at 10:56 AM, Ryan Joseph  wrote:
> 
> Ok, I'll move to this. What are the FPC options for then? I thought I could 
> do things like -Fu and -d with it.
> 
> Are include paths and unit paths the same? I just see TDefineTemplate which 
> seems to do both.

Removing the FPCOptions fixed the FindReferences but I still don't seem to be 
getting your define template system:

If I just want to add unit search paths do I do this? The user is just going to 
supply absolute paths to the language server (just like they would from the 
command line).


// add all the unit paths
for Path in Paths do
begin
DirectoryTemplate := 
TDefineTemplate.Create('Directory','','',ExpandFileName(Path),da_Directory);

  UnitPathTemplate := TDefineTemplate.Create('???','???',
UnitPathMacroName,
UnitPathMacro+';'+ExpandFileName(Path),
da_Define
);
  DirectoryTemplate.AddChild(UnitPathTemplate);

  CodeToolBoss.DefineTree.Add(DirectoryTemplate);
end;


Regards,
Ryan Joseph

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


Re: [fpc-pascal] Code tools search paths

2020-05-11 Thread Mattias Gaertner via fpc-pascal
On Mon, 11 May 2020 10:56:32 +0700
Ryan Joseph via fpc-pascal  wrote:

> > On May 10, 2020, at 4:47 PM, Mattias Gaertner via fpc-pascal
> >  wrote:
> > 
> > TDefineTemplates.
> > see for example
> > lazarus/components/codetools/examples/setincludepath.pas
> >   
> 
> Ok, I'll move to this. What are the FPC options for then? I thought I
> could do things like -Fu and -d with it.

Yes, you can.
They are treated like global options, i.e. as if added to the fpc.cfg.
 
> Are include paths and unit paths the same?

No.


> I just see TDefineTemplate which seems to do both.

There are separate macros.


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


Re: [fpc-pascal] Compiler mode for code in rtl and rtl-extra

2020-05-11 Thread Noel Duffy via fpc-pascal

On 11/05/20 7:29 pm, Michael Van Canneyt wrote:


On Mon, 11 May 2020, Noel Duffy via fpc-pascal wrote:



Example error messages:
sockets.inc(497,5) Error: Identifier not found "Result"

sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier 
RES" found


for this definition:

  function convert_hextet(const s: ShortString; out res: Word): Boolean;


You are correct. The unit is compiled in fpc mode, which means no "result"
variable, no out param (replace with var).


Great. If var is available then the job is easy.


We can envision changing this mode, but then the whole unit needs to be
verified and checked for correct functioning, since it will redefine 
basic types as integer from 16 to 32 bit, change the meaning of string.


I don't think you will want to undertake that effort :)


I don't think I want to do it either! This certainly falls under the "If 
it ain't broke" maxim.


Thanks for the fast response.


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


Re: [fpc-pascal] Compiler mode for code in rtl and rtl-extra

2020-05-11 Thread Michael Van Canneyt



On Mon, 11 May 2020, Noel Duffy via fpc-pascal wrote:

I've been beavering away at a fix for 
https://bugs.freepascal.org/view.php?id=37013 and I've run into 
something unexpected. When I try to build rtl-extra with my proposed 
patch applied, I get compiler errors for things like the use of result 
variables and var/out variables. I'm so used to these being available 
that I quite forgot there are modes where they're not.


My question is, first, what mode is the compiler using, and second, is 
this required for portability to other platforms?


The compiler uses fpc mode.


Or am I completely misunderstanding this?

Example error messages:
sockets.inc(497,5) Error: Identifier not found "Result"

sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier 
RES" found


for this definition:

  function convert_hextet(const s: ShortString; out res: Word): Boolean;

It's not a big deal to rewrite around these, but first I want to make 
sure I am correctly diagnosing the issue.


You are correct. The unit is compiled in fpc mode, which means no "result"
variable, no out param (replace with var).

We can envision changing this mode, but then the whole unit needs to be
verified and checked for correct functioning, 
since it will redefine basic types as integer from 16 to 32 bit, change the meaning of string.


I don't think you will want to undertake that effort :)

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


[fpc-pascal] Compiler mode for code in rtl and rtl-extra

2020-05-11 Thread Noel Duffy via fpc-pascal
I've been beavering away at a fix for 
https://bugs.freepascal.org/view.php?id=37013 and I've run into 
something unexpected. When I try to build rtl-extra with my proposed 
patch applied, I get compiler errors for things like the use of result 
variables and var/out variables. I'm so used to these being available 
that I quite forgot there are modes where they're not.


My question is, first, what mode is the compiler using, and second, is 
this required for portability to other platforms?


Or am I completely misunderstanding this?

Example error messages:
sockets.inc(497,5) Error: Identifier not found "Result"

sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier 
RES" found


for this definition:

  function convert_hextet(const s: ShortString; out res: Word): Boolean;

It's not a big deal to rewrite around these, but first I want to make 
sure I am correctly diagnosing the issue.


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