Pascal to C source code translator

Kevin J. Cummings cummings at kjchome.homeip.net
Sun May 22 01:23:36 UTC 2011


On 05/21/2011 08:27 PM, JD wrote:
> This is the sample pascal module:

This is not PASCAL.  It might very well be Object Pascal, which is a
(slightly) different language.  Different enough that the p2c compiler
does not know about the extensions in Object Pascal, so I can see how it
would fail.  You need to find an Object Pascal to C translator....

> unit PoTranslator;
> 
> {$mode objfpc}{$H+}
> 
> interface
> 
> uses
>    Classes, SysUtils, LResources, typinfo, Translations;
> 
> type
> 
>   { TPoTranslator }
> 
>   TPoTranslator=class(TAbstractTranslator)
>   private
>    FPOFile:TPOFile;
>   public
>    constructor Create(POFileName:string);
>    destructor Destroy;override;
>    procedure TranslateStringProperty(Sender:TObject;
>      const Instance: TPersistent; PropInfo: PPropInfo; var 
> Content:string);override;
>   end;
> 
> implementation
> 
> { TPoTranslator }
> 
> constructor TPoTranslator.Create(POFileName: string);
> begin
>    inherited Create;
>    FPOFile:=TPOFile.Create(POFileName);
> end;
> 
> destructor TPoTranslator.Destroy;
> begin
>    FPOFile.Free;
>    inherited Destroy;
> end;
> 
> procedure TPoTranslator.TranslateStringProperty(Sender: TObject;
>    const Instance: TPersistent; PropInfo: PPropInfo; var Content: string);
> var
>    s: String;
> begin
>    if not Assigned(FPOFile) then exit;
>    if not Assigned(PropInfo) then exit;
> {DO we really need this?}
>    if Instance is TComponent then
>     if csDesigning in (Instance as TComponent).ComponentState then exit;
> {End DO :)}
>    if (AnsiUpperCase(PropInfo^.PropType^.Name)<>'TTRANSLATESTRING') then 
> exit;
>    s:=FPOFile.Translate(Content, Content);
>    if s<>'' then Content:=s;
> end;
> 
> end.
> 


-- 
Kevin J. Cummings
kjchome at verizon.net
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)


More information about the users mailing list