Re: [fpc-pascal] How to know if a class implements a method
> So, at this moment I know that I can: > > 1. Use a safe, magic and efficient way, but I need to know if it exists; > 2. Create a "light" instance using vfooclass.NewInstance method; > 3. hack the vmt. > > Which approach do you use? I have worked with a bespoke OPF a few years ago. The way we got around this was to use a multitier approach and literally have the client ask the server questions in this kind of situation. The server was multithreaded and it cached information, so it usually didn't have much of an impact. So long as the network traffic was minimal and only happened once per session (the reply being cached) it worked well. We also used a complex inheritance tree with interfaces being passed back from the server rather than class references. There were also tight rules about implementing methods. Methods with no implementation were not allowed in persistently stored objects. I don't think there's much more really you can do. Other than caching the RTTI info for each class you use in this way. HTH ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to know if a class implements a method
Hello Matt, thanks for your fast input. Matt Emson wrote: Any idea how I know if a class, in a class pointer, overrides a virtual method? Eg: vfooclass := tboo1; // vfooclass doesn't implement sample. vfooclass := tboo2; // vfooclass implements sample. You need to implement a virtual method, even if it does nothing. Are you sure you're not meaning abstract method? No, no... I just want to know if the class referenced by vfooclass overrides the "sample" method, implementing something different from the virtual implementation that, btw, isn't abstract and it's empty. At this moment I know that: 1. I could cast a method pointer with tmethod if sample was a class method; 2. I could cast this same method pointer if I had an instance of vfooclass. But is there another way beyond creating an instance? You can always hack the RTTI/VMT, but that might not be a safe way. I though about this, dunno it's better than creating an useless instance. Might it be that you need to have a more complex inheritence tree? So add a few levels? Even more complex? No, no! =) This is a piece of an OPF framework. I want to know if a business class implement something in a virtual method. Such class belongs to the application and the framework doesn't have direct access to it. If the class doesn't implement I don't need to retrieve an instance from the database, btw an expensive task for absolutely nothing. So, at this moment I know that I can: 1. Use a safe, magic and efficient way, but I need to know if it exists; 2. Create a "light" instance using vfooclass.NewInstance method; 3. hack the vmt. Which approach do you use? Thanks. -- Joao Morais ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to know if a class implements a method
> Any idea how I know if a class, in a class pointer, overrides a virtual > method? Eg: > vfooclass := tboo1; > // vfooclass doesn't implement sample. > > vfooclass := tboo2; > // vfooclass implements sample. You need to implement a virtual method, even if it does nothing. Are you sure you're not meaning abstract method? e.g. TBlah = class public procedure blah; virtual; procedure blahblah; virtual; abstract; end; Will only compile if "TBlah.blah" has a body where as TBlah.blahblah" does not require itself to be implemnted. > At this moment I know that: > > 1. I could cast a method pointer with tmethod if sample was a class method; > > 2. I could cast this same method pointer if I had an instance of vfooclass. > > But is there another way beyond creating an instance? You can always hack the RTTI/VMT, but that might not be a safe way. Might it be that you need to have a more complex inheritence tree? So add a few levels? tfooBaseclass = class of tfooBase; tfooclass = class of tfoo; tfooBase = class private procedure sample; virtual; end; tfoo = class(tfooBase) public procedure sample; override; //a base implementation end; tboo1 = class(tfooBase) //sample is still private and not publicly accessable end; tboo2 = class(tfoo) public procedure sample; override; //whatever end; if (x is tfoo ) then {supports the sample}; if (x is tfooBase ) then {does not make public the sample}; You then know that tfooBaseclass never implement sample, but that all tfooClass have that method. It all seems a little confusing though. I'm not really clear what you are trying to achieve. Inheritence wants you to either make methods static, or virtual. If it is static, you can't override it, only "hide" (Replace) it. You coule also use interfaces. Then you don't need a base class: ifoo = interface private procedure sample; virtual; end; tboo1 = class( ifoo) procedure sample; end; tboo2 = class end; if (tboo is ifoo) then {supports the ifoo interface}; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] How to know if a class implements a method
Hello, Any idea how I know if a class, in a class pointer, overrides a virtual method? Eg: tfooclass = class of tfoo; tfoo = class procedure sample; virtual; end; tboo1 = class(tfoo) end; tboo2 = class(tfoo) procedure sample; override; end; ... vfooclass := tboo1; // vfooclass doesn't implement sample. vfooclass := tboo2; // vfooclass implements sample. At this moment I know that: 1. I could cast a method pointer with tmethod if sample was a class method; 2. I could cast this same method pointer if I had an instance of vfooclass. But is there another way beyond creating an instance? Thanks. -- Joao Morais ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] writing programs for non Intel Processors
> Why no? Because Windows CE <> Win32. Smartphone more so. However, the word "probably" conveyed my doubt that I had all the facts. There you go. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] accessing hardware ports in FPC
Op Fri, 18 May 2007, schreef Felipe Monteiro de Carvalho: > The port array will fail on NT versions of windows. Better to use the > methods described here: > > http://wiki.lazarus.freepascal.org/Hardware_Access Can you please implement a ports unit for Windows then? The last thing we need is people to start using OS specific code. Daniël___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] accessing hardware ports in FPC
The port array will fail on NT versions of windows. Better to use the methods described here: http://wiki.lazarus.freepascal.org/Hardware_Access -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] accessing hardware ports in FPC
Op Thu, 17 May 2007, schreef [EMAIL PROTECTED]: > Hi > I am a new user of FPC can somebody guide me how to access directly hardware > ports > with FPC http://www.freepascal.org/faq.var#accessioports Daniël___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] writing programs for non Intel Processors
On 5/17/07, Matt Emson <[EMAIL PROTECTED]> wrote: It runs Windows 2003 Smartphone though, so I'm guessing the answer is a little more tricky - probably no. Why no? Windows 2003 Smartphone is still Windows CE. Microsoft just like to give several wierd names for the different versions of Windows CE http://en.wikipedia.org/wiki/Windows_CE#Relationship_to_Windows_Mobile.2C_Pocket_PC.2C_and_SmartPhone Further, the processor is ARM 5, which FPC supports AFAIK So, we should have everything in place. -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] accessing hardware ports in FPC
Hi I am a new user of FPC can somebody guide me how to access directly hardware ports with FPC Thanks Ezra Check Out the new free AIM(R) Mail -- 2 GB of storage and industry-leading spam and email virus protection. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] writing programs for non Intel Processors
"The Motorola MPx220 runs a 200-MHz Texas Instruments OMAP 1611 processor", which is a a 32bit "ARM v5" with a " ARM926EJ-S" core. It runs Windows 2003 Smartphone though, so I'm guessing the answer is a little more tricky - probably no. M - Original Message - From: Pianoman To: fpc-pascal@lists.freepascal.org Sent: Wednesday, May 16, 2007 3:22 PM Subject: [fpc-pascal] writing programs for non Intel Processors Hello, I would like to ask whether is it possible to use freepascal to write application for example for Motorola MPX220 (mobile phone) ( it runs windows 2003 mobile edition) Pianoman -- ___ 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] ARM-Linux, building RTL fails
Hello again, with latest Trunk, Rev. 7387, building of the ARM-Linux RTL fails: ppcrossarm.exe -Tlinux -Parm -XParm-linux- -Xc -Xr -Fi../inc -Fi../arm -Fi../unix -Fiarm -FE. -FU../../rtl/units/arm-linux -Tlinux -CX -darm -Us -Sg system.pp softfpu.pp(122,12) Error: Duplicate identifier "UInt64" system.pp(52,34) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Removing UInt64 in softfpu.pp or in systemh.inc seems to solve the problem. seems to be related to bug entry 8860 (fpc complains:UInt64 not found). Regards, Bernd. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] ARM-Linux, building RTL fails
Hello, with latest Trunk, Rev. 7387, building of the ARM-Linux RTL fails: ppcrossarm.exe -Tlinux -Parm -XParm-linux- -Xc -Xr -Fi../inc -Fi../arm -Fi../unix -Fiarm -FE. -FU../../rtl/units/arm-linux -Tlinux -CX -darm -Us -Sg system.pp softfpu.pp(122,12) Error: Duplicate identifier "UInt64" system.pp(52,34) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Removing UInt64 in softfpu.pp or in systemh.inc seems to solve the problem. Regards, Bernd. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal