import.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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. {$i defines.inc}
  19. interface
  20. uses
  21. cutils,cobjects;
  22. type
  23. pimported_item = ^timported_item;
  24. timported_item = object(tlinkedlist_item)
  25. ordnr : word;
  26. name,
  27. func : pstring;
  28. lab : pointer; { should be plabel, but this gaves problems with circular units }
  29. is_var : boolean;
  30. constructor init(const n,s : string;o : word);
  31. constructor init_var(const n,s : string);
  32. destructor done;virtual;
  33. end;
  34. pimportlist = ^timportlist;
  35. timportlist = object(tlinkedlist_item)
  36. dllname : pstring;
  37. imported_items : plinkedlist;
  38. constructor init(const n : string);
  39. destructor done;virtual;
  40. end;
  41. pimportlib=^timportlib;
  42. timportlib=object
  43. private
  44. notsupmsg : boolean;
  45. procedure NotSupported;
  46. public
  47. constructor Init;
  48. destructor Done;
  49. procedure preparelib(const s:string);virtual;
  50. procedure importprocedure(const func,module:string;index:longint;const name:string);virtual;
  51. procedure importvariable(const varname,module:string;const name:string);virtual;
  52. procedure generatelib;virtual;
  53. procedure generatesmartlib;virtual;
  54. end;
  55. var
  56. importlib : pimportlib;
  57. procedure InitImport;
  58. procedure DoneImport;
  59. implementation
  60. uses
  61. systems,verbose,globals
  62. {$ifdef i386}
  63. {$ifndef NOTARGETLINUX}
  64. ,t_linux
  65. {$endif}
  66. {$ifndef NOTARGETFREEBSD}
  67. ,t_fbsd
  68. {$endif}
  69. {$ifndef NOTARGETOS2}
  70. ,t_os2
  71. {$endif}
  72. {$ifndef NOTARGETWIN32}
  73. ,t_win32
  74. {$endif}
  75. {$ifndef NOTARGETNETWARE}
  76. ,t_nwm
  77. {$endif}
  78. {$ifndef NOTARGETGO32V2}
  79. ,t_go32v2
  80. {$endif}
  81. {$endif}
  82. {$ifdef m68k}
  83. {$ifndef NOTARGETLINUX}
  84. ,t_linux
  85. {$endif}
  86. {$endif}
  87. {$ifdef powerpc}
  88. {$ifndef NOTARGETLINUX}
  89. ,t_linux
  90. {$endif}
  91. {$endif}
  92. {$ifdef alpha}
  93. {$ifndef NOTARGETLINUX}
  94. ,t_linux
  95. {$endif}
  96. {$endif}
  97. ;
  98. {****************************************************************************
  99. Timported_item
  100. ****************************************************************************}
  101. constructor timported_item.init(const n,s : string;o : word);
  102. begin
  103. inherited init;
  104. func:=stringdup(n);
  105. name:=stringdup(s);
  106. ordnr:=o;
  107. lab:=nil;
  108. is_var:=false;
  109. end;
  110. constructor timported_item.init_var(const n,s : string);
  111. begin
  112. inherited init;
  113. func:=stringdup(n);
  114. name:=stringdup(s);
  115. ordnr:=0;
  116. lab:=nil;
  117. is_var:=true;
  118. end;
  119. destructor timported_item.done;
  120. begin
  121. stringdispose(name);
  122. stringdispose(func);
  123. inherited done;
  124. end;
  125. {****************************************************************************
  126. TImportlist
  127. ****************************************************************************}
  128. constructor timportlist.init(const n : string);
  129. begin
  130. inherited init;
  131. dllname:=stringdup(n);
  132. imported_items:=new(plinkedlist,init);
  133. end;
  134. destructor timportlist.done;
  135. begin
  136. dispose(imported_items,done);
  137. stringdispose(dllname);
  138. end;
  139. {****************************************************************************
  140. TImportLib
  141. ****************************************************************************}
  142. constructor timportlib.Init;
  143. begin
  144. notsupmsg:=false;
  145. end;
  146. destructor timportlib.Done;
  147. begin
  148. end;
  149. procedure timportlib.NotSupported;
  150. begin
  151. { show the message only once }
  152. if not notsupmsg then
  153. begin
  154. Message(exec_e_dll_not_supported);
  155. notsupmsg:=true;
  156. end;
  157. end;
  158. procedure timportlib.preparelib(const s:string);
  159. begin
  160. NotSupported;
  161. end;
  162. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  163. begin
  164. NotSupported;
  165. end;
  166. procedure timportlib.importvariable(const varname,module:string;const name:string);
  167. begin
  168. NotSupported;
  169. end;
  170. procedure timportlib.generatelib;
  171. begin
  172. NotSupported;
  173. end;
  174. procedure timportlib.generatesmartlib;
  175. begin
  176. NotSupported;
  177. end;
  178. procedure DoneImport;
  179. begin
  180. if assigned(importlib) then
  181. dispose(importlib,done);
  182. end;
  183. procedure InitImport;
  184. begin
  185. case target_info.target of
  186. {$ifdef i386}
  187. target_i386_Linux :
  188. importlib:=new(pimportliblinux,Init);
  189. target_i386_freebsd:
  190. importlib:=new(pimportlibfreebsd,Init);
  191. target_i386_Win32 :
  192. importlib:=new(pimportlibwin32,Init);
  193. target_i386_OS2 :
  194. importlib:=new(pimportlibos2,Init);
  195. target_i386_Netware :
  196. importlib:=new(pimportlibnetware,Init);
  197. {$endif i386}
  198. {$ifdef m68k}
  199. target_m68k_Linux :
  200. importlib:=new(pimportliblinux,Init);
  201. {$endif m68k}
  202. {$ifdef alpha}
  203. target_alpha_Linux :
  204. importlib:=new(pimportliblinux,Init);
  205. {$endif alpha}
  206. {$ifdef powerpc}
  207. target_alpha_Linux :
  208. importlib:=new(pimportliblinux,Init);
  209. {$endif powerpc}
  210. else
  211. importlib:=new(pimportlib,Init);
  212. end;
  213. end;
  214. end.
  215. {
  216. $Log$
  217. Revision 1.6 2000-09-24 15:06:18 peter
  218. * use defines.inc
  219. Revision 1.5 2000/09/16 12:22:52 peter
  220. * freebsd support merged
  221. Revision 1.4 2000/09/11 17:00:23 florian
  222. + first implementation of Netware Module support, thanks to
  223. Armin Diehl ([email protected]) for providing the patches
  224. Revision 1.3 2000/08/27 16:11:51 peter
  225. * moved some util functions from globals,cobjects to cutils
  226. * splitted files into finput,fmodule
  227. Revision 1.2 2000/07/13 11:32:43 michael
  228. + removed logs
  229. }