Re: [fpc-pascal] Casting descendant interface variables to base
OK, I understand now. Thank you for explanation. -- cobines ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Casting descendant interface variables to base
On 30 Jan 11, at 22:28 , cobines wrote: > it is now a pointer to IBaseInterface, because of implicit QueryInterface? The reference changes because you have explicitly cast (the implementing object) to another interface. > So, I think I can compare interface variables but first I have to > bring them to the same interface using "as", for example to IUnknown. Yes. This function will confirm the two provided interfaces are implemented by the same object... function EqIntf(a, b: IUnknown): Boolean; begin Result := (a as IUnknown) = (b as IUnknown); end; Regards Andrew. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Casting descendant interface variables to base
A more detailed answer: iDesc holds TDescClass as IDescInterface iBase holds TDescClass as IDescInterface iBaseAsBase holds TBaseClass as IBaseInterface iBase holds the IDescInterface interface because they are compile-time compatible (the same as an ancestor object reference holding an object from a descendent class). iBaseAsBase explicitly casts the interface to the iBaseInterface - since the only class which implements this interface is TDescClass's ancestor, this interface reference must be used. ** If your declaration was changed thus: "TBaseClass = class(TInterfacedObject)" then the code would compile (exception for the iSelf assignment) but you would receive an "invalid typecast" at "iBaseAsBase := iBase as IBaseInterface" since TDescClass no longer supports IBaseInterface. ** If your declaration was changed thus: "TDescClass = class(TBaseClass, IBaseInterface, IDescInterface)" then iBaseAsBase would hold TDescClass as IBaseInterface. iSelf holds TBaseClass as IBaseInterface iSelfAsBase holds TBaseClass as IBaseInterface iOtherAsBase holds TBaseClass as IBaseInterface In all three of these variables, IBaseInterface is required - which is only implemented by TBaseClass - so (as with iBaseAsBase) they all hold the same reference. An interface reference points to the private data structure which defines that interface and the procedure pointers to its supported methods (for the specific implementing class) - it does not point to the implementing object (Self) - it has no way to access the implementing class structure (or contained fields). Regards Andrew. On 30 Jan 11, at 20:37 , cobines wrote: > Why does iBase have different value than iBaseAsBase? It seems simply > assigning to interface variable doesn't change it to base interface, I > have to explicitly use "as IBaseInterface". Is it correct? > > Basically, I'm trying to determine in CopyToInterface function if the > parameter points to the same object as Self. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Casting descendant interface variables to base
2011/1/31 Andrew Hall : > Interfaces do not behave like classes. Each each interface > implemented/supported by a class is unique - at runtime a "descendent" > interface is entirely unrelated to its ancestor. Ok, so in this assignment var iBase: IBaseInterface; iDesc: IDescInterface; begin iBase := iDesc; end; iBase still holds a pointer to IDescInterface of the class instance, but in this begin iBase := iDesc as IBaseInterface; end; it is now a pointer to IBaseInterface, because of implicit QueryInterface? So, I think I can compare interface variables but first I have to bring them to the same interface using "as", for example to IUnknown. -- cobines ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Casting descendant interface variables to base
Interfaces do not behave like classes. Each each interface implemented/supported by a class is unique - at runtime a "descendent" interface is entirely unrelated to its ancestor. Regards Andrew. On 30 Jan 11, at 20:37 , cobines wrote: > Hello everyone, > > I have attached a program about which I have a question. > > Why does iBase have different value than iBaseAsBase? It seems simply > assigning to interface variable doesn't change it to base interface, I > have to explicitly use "as IBaseInterface". Is it correct? > > Basically, I'm trying to determine in CopyToInterface function if the > parameter points to the same object as Self. > > -- > cobines > ___ > 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
[fpc-pascal] Casting descendant interface variables to base
Hello everyone, I have attached a program about which I have a question. Why does iBase have different value than iBaseAsBase? It seems simply assigning to interface variable doesn't change it to base interface, I have to explicitly use "as IBaseInterface". Is it correct? Basically, I'm trying to determine in CopyToInterface function if the parameter points to the same object as Self. -- cobines project1.lpr Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC + Haiku
Hi, On 28/01/2011 13:41, Marco van de Voort wrote: In our previous episode, Matt Emson said: Anybody here using FPC on Haiku? If so, how well does it work compared to under Windows or Linux? Yes, me ! It should work well. But, as you can imagine, there is a lot less testers under Haiku. So, bugs might remains here and there. Feel free to submit bugs or patchs in the bug tracker. It used to work well enough under BeOS R5, but there was always an issue with the C++ nature of the Be API. Haiku seems to have a Qt port, so you might get further with it. I seem to recall Lazarus can target Qt, right? Afaik Lazarus runs on Haiku due to the work of mostly Olivier Coursiere. (it was GTK2 based iirc). Qt based in fact ;-) But, yes, Lazarus runs quite well. Integrated debugging does not work. I have not yet look at this problem (it might work one day as it already works in the textmode IDE). There is a few problems in the designer when dragging components (probably some bugs in Haiku's Qt port). The number of haiku patches is slow, but every FPC release contains a couple. Yes, i try to compile freepascal on a regular basis under Haiku and submit patchs when needed or when i found something. But any help is welcome ;-) Regards, Olivier ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building FPC on LFS system
On 30 Jan 2011, at 18:17, Geoffray Levasseur wrote: > On Sunday 30 January 2011 14:49:29 Jonas Maebe wrote: >> Not really. The default -O2 will be pretty much optimal. Only if you have >> an SSE3 capable cpu, you can add OPT="-Cfsse3" at the end of make command >> line. It won't make much of a difference though, as it only affects >> certain float to int conversions. >> > OK right just basic things so... Mayby any 64 bits optimizations (I'm > thinking > about a -m64 equivalent to gcc)? ppcx64 will always generate code that is the equivalent of gcc -m64. For gcc -m32 code, you have to compile a ppc386 instead (bootstrap compiler is also available in the same directory). The generic compiler driver (similar to the "gcc" program for GCC) is called "fpc", and selecting the target processor happens using its -P option (-Pi386, -Px86_64). That one will call through to ppcx64, ppc386, ... Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building FPC on LFS system
On Sunday 30 January 2011 14:42:10 ik wrote: > LFS is usually installed from an existed linux distro, so you should > install it on the hosting linux, and then compile it to your own distro > (LFS is to build your own base at least). Yes that's a possibility but bootstraping is cleaner so I prefer the third possibility (the one from Jonas). Nevertheless I keep this option in mind. Thanks -- Geoffray « fatalerrors » Levasseur http://jeff.levasseur.tuxfamily.org GNU-PG public key: B0EC11B62617B11A582A7C4226573BFD878E334D Sic luceat lux et pax. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building FPC on LFS system
On Sunday 30 January 2011 14:49:29 Jonas Maebe wrote: > On 30 Jan 2011, at 14:35, Geoffray Levasseur wrote: > > I suppose I'll have to download a precompiled version for my system > > (x86_64) but I want do do this in a clean way. > > Assuming "LFS" in your mail meant "Linux From Scratch", you can a download > bootstrap binary from > ftp://ftp.freepascal.org/fpc/dist/2.4.0/bootstrap/ppcx64-x86_64-linux.bz2 > (it seems no bootstrap compiler for Linux/x86_64 was uploaded for 2.4.2, > but the 2.4.0 binary can be used to bootstrap 2.4.2). > Perfect this is exactly what I was looking for. > > Another question: is there any usefull optimization flags (just like > > CFLAGS)? > > Not really. The default -O2 will be pretty much optimal. Only if you have > an SSE3 capable cpu, you can add OPT="-Cfsse3" at the end of make command > line. It won't make much of a difference though, as it only affects > certain float to int conversions. > OK right just basic things so... Mayby any 64 bits optimizations (I'm thinking about a -m64 equivalent to gcc)? > > Jonas___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal Thanks -- Geoffray « fatalerrors » Levasseur http://jeff.levasseur.tuxfamily.org GNU-PG public key: B0EC11B62617B11A582A7C4226573BFD878E334D Sic luceat lux et pax. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building FPC on LFS system
On 30 Jan 2011, at 14:35, Geoffray Levasseur wrote: > I suppose I'll have to download a precompiled version for my system (x86_64) > but I want do do this in a clean way. Assuming "LFS" in your mail meant "Linux From Scratch", you can a download bootstrap binary from ftp://ftp.freepascal.org/fpc/dist/2.4.0/bootstrap/ppcx64-x86_64-linux.bz2 (it seems no bootstrap compiler for Linux/x86_64 was uploaded for 2.4.2, but the 2.4.0 binary can be used to bootstrap 2.4.2). > Another question: is there any usefull optimization flags (just like CFLAGS)? Not really. The default -O2 will be pretty much optimal. Only if you have an SSE3 capable cpu, you can add OPT="-Cfsse3" at the end of make command line. It won't make much of a difference though, as it only affects certain float to int conversions. Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building FPC on LFS system
On Sun, Jan 30, 2011 at 15:35, Geoffray Levasseur wrote: > Hi everybody... > > My problem is simple. As far as I know there's no way to build FPC without > FPC. So can anybody can tell me how to bootstrap FPC to build it on a LFS > system without FPC installed? > LFS is usually installed from an existed linux distro, so you should install it on the hosting linux, and then compile it to your own distro (LFS is to build your own base at least). > > I suppose I'll have to download a precompiled version for my system > (x86_64) > but I want do do this in a clean way. > > Another question: is there any usefull optimization flags (just like > CFLAGS)? > > Thanks. > -- > Geoffray « fatalerrors » Levasseur > http://jeff.levasseur.tuxfamily.org > GNU-PG public key: B0EC11B62617B11A582A7C4226573BFD878E334D > Sic luceat lux et pax. > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > Ido LINESIP - Opening the source for communication http://www.linesip.com http://www.linesip.co.il ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building FPC on LFS system
In our previous episode, Geoffray Levasseur said: > > My problem is simple. As far as I know there's no way to build FPC without > FPC. So can anybody can tell me how to bootstrap FPC to build it on a LFS > system without FPC installed? Crosscompile. Either by entirely linking on host, or to assembler and assembling/linking on target. Note that the core FPC binaries are static by default, which eases this a bit. > I suppose I'll have to download a precompiled version for my system (x86_64) > but I want do do this in a clean way. > > Another question: is there any usefull optimization flags (just like CFLAGS)? See -O and friends in fpc -h ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Building FPC on LFS system
Hi everybody... My problem is simple. As far as I know there's no way to build FPC without FPC. So can anybody can tell me how to bootstrap FPC to build it on a LFS system without FPC installed? I suppose I'll have to download a precompiled version for my system (x86_64) but I want do do this in a clean way. Another question: is there any usefull optimization flags (just like CFLAGS)? Thanks. -- Geoffray « fatalerrors » Levasseur http://jeff.levasseur.tuxfamily.org GNU-PG public key: B0EC11B62617B11A582A7C4226573BFD878E334D Sic luceat lux et pax. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Converting .doc and/or .html to .pdf
Hello Bo, Sunday, January 30, 2011, 9:46:22 AM, you wrote: BB> And now this thread appears here that is very similar to what I need. BB> If a Lazarus/FPC implementation is created, possibly using the BB> OpenOffice hook described here, I would be very much interested too! Please, forget my last post... I completly missunderstood the idea. My apologizes. -- Best regards, José ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: How to use GetElementById?
Title: Re: [fpc-pascal] Re: How to use GetElementById? On Sunday, January 30, 2011 13:52 silvioprog wrote: Sorry... but nobody? :( Well, when you crosspost to two mailing lists (which you shouldn't ...), then also check both of them ;-) There was an answer on the Lazarus ML. -- Best Regards, Andreas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: Converting .doc and/or .html to .pdf
Hello Bo, Sunday, January 30, 2011, 9:46:22 AM, you wrote: BB> The problem is that in order to read them one must have an instance of BB> MSOffice installed and it sometimes takes a long time to open each BB> document too. So I have been on the lookout for some way to implement BB> a program for converting these to PDF. BB> As an example all our drawings are stored for access by production in BB> PDF format, which is very simple to use (and quick if one refrains BB> from using the Adobe reader). BB> And now this thread appears here that is very similar to what I need. BB> If a Lazarus/FPC implementation is created, possibly using the BB> OpenOffice hook described here, I would be very much interested too! I had done this in Delphi in the past years using the Adobe Reader 5 OCX and a Virtual PDF Printer. Maybe I have the code somewhere. -- Best regards, José ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: How to use GetElementById?
Sorry... but nobody? :( 2011/1/26 silvioprog > Hi guys, > > I use the GetElementById in PHP with sucess, but in FPC I not know how use. > > In PHP I use (with sucess): > > ... > $dom = new DOMDocument(); > @$dom->loadHTML($data); > $return = @$dom->getElementById('currency_converter_result') > ->getElementsByTagName('span')->item(0)->firstChild->wholeText; > ... > > In FPC I try (but without sucess): > > ... > var > VHTMLDocument: THTMLDocument = nil; > begin > try > ReadHTMLFile(VHTMLDocument, '../HTML/index.htm'); > ShowMessage(VHTMLDocument.GetElementById('currency_converter_result' > ).GetElementsByTagName('span').Item[0].FirstChild.TextContent); > ... > > I found a 'generic' solution: > > > > ShowMessage(VHTMLDocument.GetElementsByTagName('div').Item[5].TextContent); > // This is a unique alternative? :o > > > Any idea? The GetElementById function works? :/ > > Project to reproduce my problema in attached (with the HTML and PHP files). > > ( sorry for my bad english ^^' ) > > Thanks. > -- *Silvio Clécio* *Blog.* blog.silvioprog.com.br *Twitter.* twitter.com/silvioprog ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Converting .doc and/or .html to .pdf
On Sunday, January 30, 2011 11:07 Andreas Schneider wrote: >On Sunday, January 30, 2011 09:46 Bo Berglund wrote: >> The link above goes in the end to a download of *compiled* java code >> so it is not that good for me. An FPC implementation would be really >> useful though. > > >The source code of jodconverter is available, as you can see on that >very page I linked (on the bottom ;-)). Automating OOo with FPC is not >completely impossible, but far from trivial. Even if you have the >necessary code, you still have to setup the ABI between OOos C++ >interface and FPC. That's essentially what the current Pascal UNO >Bridge does. But as I said: far from trivial. >That's one of the reasons I did all my OpenOffice.org extensions in >Java ;-) > >-- >Best Regards, >Andreas Right, after I wrote my message I realized I had a WinXP virtual machine with OpenOffice 3.2 installed, so I downloaded the converter and tested it using the manual command line commands. It worked OK to convert a 2-page test document. :-) I have a question in this context, tha you might answer: In the description you are directed to starting OpenOffice.org in headless mode as a socket server. Then the Java application can connect to it and make the conversion. But what is NOT specified is how you get rid of the headless running OpenOffice application... I don't want it running after I am done with my conversion. Is there a way except through TaskManager (provided it only loads the two files exe and bin)??? A will heed your advice concerning the coding and not dive in due to the complexity. Will instead try to utilize the java function via a TProcess object such that I can manage the files that are to be converted. *That* shouldn't be too difficult to do in Lazarus/FPC... -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Converting .doc and/or .html to .pdf
On Fri, 28 Jan 2011 22:27:17 +0100, Andreas Schneider wrote: >On Friday, January 28, 2011 15:52 Marcos Douglas wrote: >>> You're right. The command line is more simple. >>> Thanks for the tip, I will try this. > >> I have not found > >Since you also mentioned that you need to access it from ASP, I guess >that one might offer you the most flexibility: >http://www.artofsolving.com/opensource/jodconverter > >... because you can run it as webservice. Or you can simply invoke it >from commandline. Interesting, I have been looking for some way to convert a large number of Word documents to PDF in some automated way without using MS Office, because as far as I have seen it would have to be done manually by printing to a PDF printer. The company I work for has a system for writing up purchase specifications for all the parts we use as standardized documents in Word format. There are literally thousands of these. The problem is that in order to read them one must have an instance of MSOffice installed and it sometimes takes a long time to open each document too. So I have been on the lookout for some way to implement a program for converting these to PDF. As an example all our drawings are stored for access by production in PDF format, which is very simple to use (and quick if one refrains from using the Adobe reader). And now this thread appears here that is very similar to what I need. If a Lazarus/FPC implementation is created, possibly using the OpenOffice hook described here, I would be very much interested too! The link above goes in the end to a download of *compiled* java code so it is not that good for me. An FPC implementation would be really useful though. -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal