/components/simpleideintf/examples/testh2pastool.lpr

http://github.com/graemeg/lazarus · Unknown · 99 lines · 85 code · 14 blank · 0 comment · 0 complexity · e54f538171b1ed8cb0be613ef9e78576 MD5 · raw file

  1. { Copyright (C) 2007 Mattias Gaertner
  2. This source is free software; you can redistribute it and/or modify it under
  3. the terms of the GNU General Public License as published by the Free
  4. Software Foundation; either version 2 of the License, or (at your option)
  5. any later version.
  6. This code is distributed in the hope that it will be useful, but WITHOUT ANY
  7. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  9. details.
  10. A copy of the GNU General Public License is available on the World Wide Web
  11. at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
  12. to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  13. MA 02111-1307, USA.
  14. Abstract:
  15. Program to test single conversion tools.
  16. }
  17. program TestH2pasTool;
  18. {$mode objfpc}{$H+}
  19. uses
  20. Interfaces, Classes, SysUtils, H2PasWizard, H2PasConvert, IDETextConverter,
  21. SimpleIDEIntf, FileUtil;
  22. procedure TestTReplaceImplicitTypes(Converter: TIDETextConverter);
  23. var
  24. Tool: TReplaceImplicitTypes;
  25. begin
  26. Tool:=nil;
  27. try
  28. Tool:=TReplaceImplicitTypes.Create(nil);
  29. Tool.Execute(Converter);
  30. finally
  31. Tool.Free;
  32. end;
  33. end;
  34. procedure TestTFixArrayOfParameterType(Converter: TIDETextConverter);
  35. var
  36. Tool: TFixArrayOfParameterType;
  37. begin
  38. Tool:=nil;
  39. try
  40. Tool:=TFixArrayOfParameterType.Create(nil);
  41. Tool.Execute(Converter);
  42. finally
  43. Tool.Free;
  44. end;
  45. end;
  46. procedure TestTConvertFunctionTypesToPointers(Converter: TIDETextConverter);
  47. var
  48. Tool: TConvertFunctionTypesToPointers;
  49. begin
  50. Tool:=nil;
  51. try
  52. Tool:=TConvertFunctionTypesToPointers.Create(nil);
  53. Tool.Execute(Converter);
  54. finally
  55. Tool.Free;
  56. end;
  57. end;
  58. var
  59. Filename: String;
  60. Converter: TIDETextConverter;
  61. TempFilename: String;
  62. begin
  63. if ParamCount<1 then
  64. raise Exception.Create('Missing filename');
  65. Filename:=ParamStr(1);
  66. if not FileExists(Filename) then
  67. raise Exception.Create('File not found: "'+Filename+'"');
  68. Converter:=nil;
  69. try
  70. // create a copy of the file, so that the test does no harm
  71. TempFilename:=TextConverterToolClasses.GetTempFilename;
  72. CopyFile(Filename,TempFilename,false);
  73. // create the converter
  74. Converter:=TIDETextConverter.Create(nil);
  75. Converter.InitWithFilename(TempFilename);
  76. // test
  77. TestTReplaceImplicitTypes(Converter);
  78. TestTFixArrayOfParameterType(Converter);
  79. TestTConvertFunctionTypesToPointers(Converter);
  80. // write result
  81. writeln(Converter.Source);
  82. finally
  83. Converter.Free;
  84. end;
  85. end.