import.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Peter Vreman
  4. This unit implements an uniform import object
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. unit import;
  18. interface
  19. uses
  20. cobjects;
  21. type
  22. pimported_procedure = ^timported_procedure;
  23. timported_procedure = object(tlinkedlist_item)
  24. ordnr : word;
  25. name,func : pstring;
  26. lab : pointer; { should be plabel, but this gaves problems with circular units }
  27. constructor init(const n,s : string;o : word);
  28. destructor done;virtual;
  29. end;
  30. pimportlist = ^timportlist;
  31. timportlist = object(tlinkedlist_item)
  32. dllname : pstring;
  33. imported_procedures : plinkedlist;
  34. constructor init(const n : string);
  35. destructor done;virtual;
  36. end;
  37. pimportlib=^timportlib;
  38. timportlib=object
  39. constructor Init;
  40. destructor Done;
  41. procedure preparelib(const s:string);virtual;
  42. procedure importprocedure(const func,module:string;index:longint;const name:string);virtual;
  43. procedure generatelib;virtual;
  44. end;
  45. var
  46. importlib : pimportlib;
  47. procedure InitImport;
  48. procedure DoneImport;
  49. implementation
  50. uses
  51. systems,verbose,globals
  52. {$ifdef i386}
  53. ,os2_targ
  54. ,win_targ
  55. {$endif}
  56. ;
  57. {****************************************************************************
  58. TImported_procedure
  59. ****************************************************************************}
  60. constructor timported_procedure.init(const n,s : string;o : word);
  61. begin
  62. inherited init;
  63. func:=stringdup(n);
  64. name:=stringdup(s);
  65. ordnr:=o;
  66. lab:=nil;
  67. end;
  68. destructor timported_procedure.done;
  69. begin
  70. stringdispose(name);
  71. inherited done;
  72. end;
  73. {****************************************************************************
  74. TImportlist
  75. ****************************************************************************}
  76. constructor timportlist.init(const n : string);
  77. begin
  78. inherited init;
  79. dllname:=stringdup(SplitName(n));
  80. imported_procedures:=new(plinkedlist,init);
  81. end;
  82. destructor timportlist.done;
  83. begin
  84. dispose(imported_procedures,done);
  85. stringdispose(dllname);
  86. end;
  87. {****************************************************************************
  88. TImportLib
  89. ****************************************************************************}
  90. constructor timportlib.Init;
  91. begin
  92. end;
  93. destructor timportlib.Done;
  94. begin
  95. end;
  96. procedure timportlib.preparelib(const s:string);
  97. begin
  98. Message(exec_e_dll_not_supported);
  99. end;
  100. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  101. begin
  102. Message(exec_e_dll_not_supported);
  103. end;
  104. procedure timportlib.generatelib;
  105. begin
  106. Message(exec_e_dll_not_supported);
  107. end;
  108. procedure DoneImport;
  109. begin
  110. if assigned(importlib) then
  111. dispose(importlib,done);
  112. end;
  113. procedure InitImport;
  114. begin
  115. {$ifdef i386}
  116. case target_info.target of
  117. target_Win32 : importlib:=new(pimportlibwin32,Init);
  118. target_OS2 : importlib:=new(pimportlibos2,Init);
  119. else
  120. importlib:=new(pimportlib,Init);
  121. end;
  122. {$endif i386}
  123. {$ifdef m68k}
  124. importlib:=new(pimportlib,Init);
  125. {$endif m68k}
  126. end;
  127. end.
  128. {
  129. $Log$
  130. Revision 1.5 1998-10-06 17:16:51 pierre
  131. * some memory leaks fixed (thanks to Peter for heaptrc !)
  132. Revision 1.4 1998/09/30 12:16:47 peter
  133. * remove extension if one is specified
  134. Revision 1.3 1998/06/04 23:51:43 peter
  135. * m68k compiles
  136. + .def file creation moved to gendef.pas so it could also be used
  137. for win32
  138. Revision 1.2 1998/04/27 23:10:28 peter
  139. + new scanner
  140. * $makelib -> if smartlink
  141. * small filename fixes pmodule.setfilename
  142. * moved import from files.pas -> import.pas
  143. Revision 1.1.1.1 1998/03/25 11:18:12 root
  144. * Restored version
  145. Revision 1.3 1998/03/10 01:17:19 peter
  146. * all files have the same header
  147. * messages are fully implemented, EXTDEBUG uses Comment()
  148. + AG... files for the Assembler generation
  149. Revision 1.2 1998/03/06 00:52:21 peter
  150. * replaced all old messages from errore.msg, only ExtDebug and some
  151. Comment() calls are left
  152. * fixed options.pas
  153. }