import.pas 6.0 KB

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