import.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. Copyright (c) 1998-2002 by Peter Vreman
  3. This unit implements an uniform import object
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. unit import;
  17. {$i fpcdefs.inc}
  18. interface
  19. uses
  20. systems;
  21. type
  22. timportlib=class
  23. private
  24. notsupmsg : boolean;
  25. procedure NotSupported;
  26. public
  27. constructor Create;virtual;
  28. destructor Destroy;override;
  29. procedure generatelib;virtual;
  30. end;
  31. TDLLScanner=class
  32. function Scan(const binname:string):boolean;virtual;abstract;
  33. end;
  34. TImportLibClass=class of TImportLib;
  35. TDLLScannerClass=class of TDLLScanner;
  36. var
  37. CImportLib : array[tsystem] of TImportLibClass;
  38. CDLLScanner : array[tsystem] of TDLLScannerClass;
  39. ImportLib : TImportLib;
  40. procedure RegisterImport(t:tsystem;c:TImportLibClass);
  41. procedure RegisterDLLScanner(t:tsystem;c:TDLLScannerClass);
  42. procedure InitImport;
  43. procedure DoneImport;
  44. implementation
  45. uses
  46. verbose,globals;
  47. {****************************************************************************
  48. TImportLib
  49. ****************************************************************************}
  50. constructor timportlib.Create;
  51. begin
  52. notsupmsg:=false;
  53. end;
  54. destructor timportlib.Destroy;
  55. begin
  56. end;
  57. procedure timportlib.NotSupported;
  58. begin
  59. { show the message only once }
  60. if not notsupmsg then
  61. begin
  62. Message(exec_e_dll_not_supported);
  63. notsupmsg:=true;
  64. end;
  65. end;
  66. procedure timportlib.generatelib;
  67. begin
  68. NotSupported;
  69. end;
  70. {*****************************************************************************
  71. Init/Done
  72. *****************************************************************************}
  73. procedure RegisterImport(t:tsystem;c:TImportLibClass);
  74. begin
  75. CImportLib[t]:=c;
  76. end;
  77. procedure RegisterDLLScanner(t:tsystem;c:TDLLScannerClass);
  78. begin
  79. CDLLScanner[t]:=c;
  80. end;
  81. procedure InitImport;
  82. begin
  83. if assigned(CImportLib[target_info.system]) then
  84. importlib:=CImportLib[target_info.system].Create
  85. else
  86. importlib:=TImportLib.Create;
  87. end;
  88. procedure DoneImport;
  89. begin
  90. if assigned(importlib) then
  91. importlib.free;
  92. end;
  93. end.