import.pas 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. ,lin_targ
  57. ;
  58. {****************************************************************************
  59. TImported_procedure
  60. ****************************************************************************}
  61. constructor timported_procedure.init(const n,s : string;o : word);
  62. begin
  63. inherited init;
  64. func:=stringdup(n);
  65. name:=stringdup(s);
  66. ordnr:=o;
  67. lab:=nil;
  68. end;
  69. destructor timported_procedure.done;
  70. begin
  71. stringdispose(name);
  72. inherited done;
  73. end;
  74. {****************************************************************************
  75. TImportlist
  76. ****************************************************************************}
  77. constructor timportlist.init(const n : string);
  78. begin
  79. inherited init;
  80. dllname:=stringdup(n);
  81. imported_procedures:=new(plinkedlist,init);
  82. end;
  83. destructor timportlist.done;
  84. begin
  85. dispose(imported_procedures,done);
  86. stringdispose(dllname);
  87. end;
  88. {****************************************************************************
  89. TImportLib
  90. ****************************************************************************}
  91. constructor timportlib.Init;
  92. begin
  93. end;
  94. destructor timportlib.Done;
  95. begin
  96. end;
  97. procedure timportlib.preparelib(const s:string);
  98. begin
  99. Message(exec_e_dll_not_supported);
  100. end;
  101. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  102. begin
  103. Message(exec_e_dll_not_supported);
  104. end;
  105. procedure timportlib.generatelib;
  106. begin
  107. Message(exec_e_dll_not_supported);
  108. end;
  109. procedure DoneImport;
  110. begin
  111. if assigned(importlib) then
  112. dispose(importlib,done);
  113. end;
  114. procedure InitImport;
  115. begin
  116. case target_info.target of
  117. {$ifdef i386}
  118. target_i386_Linux :
  119. importlib:=new(pimportliblinux,Init);
  120. target_i386_Win32 :
  121. importlib:=new(pimportlibwin32,Init);
  122. target_i386_OS2 :
  123. importlib:=new(pimportlibos2,Init);
  124. {$endif i386}
  125. {$ifdef m68k}
  126. target_m68k_Linux :
  127. importlib:=new(pimportliblinux,Init);
  128. {$endif m68k}
  129. else
  130. importlib:=new(pimportlib,Init);
  131. end;
  132. end;
  133. end.
  134. {
  135. $Log$
  136. Revision 1.8 1998-10-19 18:07:12 peter
  137. + external dll_name name func support for linux
  138. Revision 1.7 1998/10/19 15:41:02 peter
  139. * better splitname to support glib-1.1.dll alike names
  140. Revision 1.6 1998/10/13 13:10:17 peter
  141. * new style for m68k/i386 infos and enums
  142. Revision 1.5 1998/10/06 17:16:51 pierre
  143. * some memory leaks fixed (thanks to Peter for heaptrc !)
  144. Revision 1.4 1998/09/30 12:16:47 peter
  145. * remove extension if one is specified
  146. Revision 1.3 1998/06/04 23:51:43 peter
  147. * m68k compiles
  148. + .def file creation moved to gendef.pas so it could also be used
  149. for win32
  150. Revision 1.2 1998/04/27 23:10:28 peter
  151. + new scanner
  152. * $makelib -> if smartlink
  153. * small filename fixes pmodule.setfilename
  154. * moved import from files.pas -> import.pas
  155. Revision 1.1.1.1 1998/03/25 11:18:12 root
  156. * Restored version
  157. Revision 1.3 1998/03/10 01:17:19 peter
  158. * all files have the same header
  159. * messages are fully implemented, EXTDEBUG uses Comment()
  160. + AG... files for the Assembler generation
  161. Revision 1.2 1998/03/06 00:52:21 peter
  162. * replaced all old messages from errore.msg, only ExtDebug and some
  163. Comment() calls are left
  164. * fixed options.pas
  165. }