2
0

import.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. cutils,cclasses,
  21. systems,
  22. aasmbase,
  23. symdef,symsym;
  24. type
  25. timportlib=class
  26. private
  27. notsupmsg : boolean;
  28. procedure NotSupported;
  29. public
  30. constructor Create;virtual;
  31. destructor Destroy;override;
  32. procedure generatelib;virtual;
  33. end;
  34. TDLLScanner=class
  35. function Scan(const binname:string):boolean;virtual;abstract;
  36. end;
  37. TImportLibClass=class of TImportLib;
  38. TDLLScannerClass=class of TDLLScanner;
  39. var
  40. CImportLib : array[tsystem] of TImportLibClass;
  41. CDLLScanner : array[tsystem] of TDLLScannerClass;
  42. ImportLib : TImportLib;
  43. procedure RegisterImport(t:tsystem;c:TImportLibClass);
  44. procedure RegisterDLLScanner(t:tsystem;c:TDLLScannerClass);
  45. procedure InitImport;
  46. procedure DoneImport;
  47. implementation
  48. uses
  49. verbose,globals;
  50. {****************************************************************************
  51. TImportLib
  52. ****************************************************************************}
  53. constructor timportlib.Create;
  54. begin
  55. notsupmsg:=false;
  56. end;
  57. destructor timportlib.Destroy;
  58. begin
  59. end;
  60. procedure timportlib.NotSupported;
  61. begin
  62. { show the message only once }
  63. if not notsupmsg then
  64. begin
  65. Message(exec_e_dll_not_supported);
  66. notsupmsg:=true;
  67. end;
  68. end;
  69. procedure timportlib.generatelib;
  70. begin
  71. NotSupported;
  72. end;
  73. {*****************************************************************************
  74. Init/Done
  75. *****************************************************************************}
  76. procedure RegisterImport(t:tsystem;c:TImportLibClass);
  77. begin
  78. CImportLib[t]:=c;
  79. end;
  80. procedure RegisterDLLScanner(t:tsystem;c:TDLLScannerClass);
  81. begin
  82. CDLLScanner[t]:=c;
  83. end;
  84. procedure InitImport;
  85. begin
  86. if assigned(CImportLib[target_info.system]) then
  87. importlib:=CImportLib[target_info.system].Create
  88. else
  89. importlib:=TImportLib.Create;
  90. end;
  91. procedure DoneImport;
  92. begin
  93. if assigned(importlib) then
  94. importlib.free;
  95. end;
  96. end.