Re: [fpc-pascal] More doubts on C to pascal header translations:
In our previous episode, Paulo Costa said: > I saw that h2pas translated: > > typedef void(*callback)(int pos, void* userdata); > > to > > callback = procedure (pos:cint; var userdata:pointer);cdecl; userdata is essentially untyped, so it doesn't matter what it exactly points too. > shouldn't it be? > > callback = procedure (pos:cint; userdata:pointer);cdecl; It is a better translation, and also pointer style support NIL. Do you use -v or not? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : [fpc-pascal] run pascal programs as scripts
> One solution: > PATH=YourDirectory:$PATH; script.pas I prefer to keep the PATH intact. I'll use: bash -c "PATH=YourDirectory:$PATH; script.pas" > Another solution: > A parameter could be added to instantfpc to specify the compiler. Would be the most elegant solution. I understand the "search in the directory of calling program first" is not very Linux though. > This is is how shebang works internally. I didn't know the internals of shebang until I wrote > instantfpc. That's why I think a user does not need that information. Learned also something new. Thanks, Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Mattias Gaertner Envoyé : samedi 23 avril 2011 20:57 À : fpc-pascal@lists.freepascal.org Objet : Re: [fpc-pascal] run pascal programs as scripts On Sat, 23 Apr 2011 20:27:37 +0200 "Ludo Brands" wrote: > Nice tool. > > 2 requests: > - I would like to select the compiler. I'm typically working with the > svn version of compiler but have in my PATH a stable version of the > compiler. > >From the sources I can see that the compiler is searched for only in > >the > PATH. A simple solution would be to look first for the compiler in the > path specified in the shebang and, if not found, then in the PATH. One solution: PATH=YourDirectory:$PATH; script.pas Another solution: A parameter could be added to instantfpc to specify the compiler. > - I was going to ask for the possibility of passing parameters to the > program. Just like a normal script: script.pas param1 > Scripts without the possiblity to pass parameters are not really > usefull. Indeed, that would be total crap. > And we do't want to put parameters in the program neither since it > would be re-compiled everytime the parameters change. Looking at the > source I figured out that the compiler parameters stop at the first > parameter not starting with a "-" Yes, that parameter is the "script.pas". > and passes the rest on to the program. Great,needs to be added to the > documentation, This is is how shebang works internally. I didn't know the internals of shebang until I wrote instantfpc. That's why I think a user does not need that information. > but... The cache is compared to the complete > script, including the shebang. So if a program parameter is changed, > the program is re-compiled... The shebang is commented out but program > parameters should be removed before compare. Recompiling if compiler > parameters change is OK. The shebang contains the parameters for the compiler, not for the script. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Mon, 25 Apr 2011 10:24:58 +0200 "Ludo Brands" wrote: > > One solution: > > PATH=YourDirectory:$PATH; script.pas > > I prefer to keep the PATH intact. I'll use: > bash -c "PATH=YourDirectory:$PATH; script.pas" That's the same. To change the PATH you must use export PATH= in bash. > > Another solution: > > A parameter could be added to instantfpc to specify the compiler. > > Would be the most elegant solution. I understand the "search in the > directory of calling program first" is not very Linux though. I added the option --compiler=. It's already in the fpc version of instantfpc. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE : [fpc-pascal] run pascal programs as scripts
> I added the option --compiler=. It's already in the fpc version of instantfpc. Great, thanks. Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Mattias Gaertner Envoyé : lundi 25 avril 2011 11:34 À : fpc-pascal@lists.freepascal.org Objet : Re: [fpc-pascal] run pascal programs as scripts On Mon, 25 Apr 2011 10:24:58 +0200 "Ludo Brands" wrote: > > One solution: > > PATH=YourDirectory:$PATH; script.pas > > I prefer to keep the PATH intact. I'll use: > bash -c "PATH=YourDirectory:$PATH; script.pas" That's the same. To change the PATH you must use export PATH= in bash. > > Another solution: > > A parameter could be added to instantfpc to specify the compiler. > > Would be the most elegant solution. I understand the "search in the > directory of calling program first" is not very Linux though. I added the option --compiler=. It's already in the fpc version of instantfpc. Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] More doubts on C to pascal header translations:
On 25/04/2011 08:58, Marco van de Voort wrote: In our previous episode, Paulo Costa said: I saw that h2pas translated: typedef void(*callback)(int pos, void* userdata); to callback = procedure (pos:cint; var userdata:pointer);cdecl; userdata is essentially untyped, so it doesn't matter what it exactly points too. Right. The trouble here was that I see var foo as a reference to foo, which means an implicit pointer. So var userdata:pointer is like a pointer to pointer and that doesn't look like the original C code... shouldn't it be? callback = procedure (pos:cint; userdata:pointer);cdecl; It is a better translation, and also pointer style support NIL. Do you use -v or not? OK. I did not use the -v option so I was wondering why it was selecting the first option. Paulo Costa ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] A few doubts about C to pascal header translations:
On 24/04/2011 16:41, Marco van de Voort wrote: In our previous episode, Paulo Costa said: I've come across some constructs that I'm not sure how to translate: A procedure where one of the arguments is declared as: size_t arg; also a macro where appears: sizeof(size_t) I replaced size_t by PtrUInt, is there a better alternative? On *nix size_t is afaik declared in unit baseunix? Right now I'm working in Linux but I latter would like to make it work in Windows. The main concern was if it was 32/64 bits safe. Paulo Costa ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] A few doubts about C to pascal header translations:
In our previous episode, Paulo Costa said: > >> I replaced size_t by PtrUInt, is there a better alternative? > > > > On *nix size_t is afaik declared in unit baseunix? > > > > Right now I'm working in Linux but I latter would like to make it work > in Windows. The main concern was if it was 32/64 bits safe. Then use the FPC internal types, sizeint,sizeuint (size of an allocation) or ptrint/ptruint (size of a pointer). This because we don't operate on windows via a posix-like layer, but by direct winapi, and follow the typing of the windows api headers, which are generally not unixy. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
Instantfpc seems to work fine under FreeBSD/32-bit too. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] run pascal programs as scripts
On Apr 23, 2011, at 7:33 PM, Mattias Gaertner wrote: > On Sun, 27 Mar 2011 19:05:12 +0200 (CEST) > Michael Van Canneyt wrote: > >> >> >> On Sun, 27 Mar 2011, Mattias Gaertner wrote: >> >>> I wrote a little tool: >>> >>> http://wiki.lazarus.freepascal.org/InstantFPC >> >> Nice job. OK to include in FPC as one of the utils ? > > Are there any outstanding issues? > Yes I have one, I would like to request adding a pascal script executable extension to the tool. Someting like .ppx for instance and have the installers for fpc and lazarus modified to register this extension also with instantfpc. Regards, Darius ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal