import.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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,cclasses;
  22. type
  23. timported_item = class(tlinkedlistitem)
  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 Create(const n,s : string;o : word);
  30. constructor Create_var(const n,s : string);
  31. destructor Destroy;override;
  32. end;
  33. timportlist = class(tlinkedlistitem)
  34. dllname : pstring;
  35. imported_items : tlinkedlist;
  36. constructor Create(const n : string);
  37. destructor Destroy;Override;
  38. end;
  39. timportlib=class
  40. private
  41. notsupmsg : boolean;
  42. procedure NotSupported;
  43. public
  44. constructor Create;
  45. destructor Destroy;override;
  46. procedure preparelib(const s:string);virtual;
  47. procedure importprocedure(const func,module:string;index:longint;const name:string);virtual;
  48. procedure importvariable(const varname,module:string;const name:string);virtual;
  49. procedure generatelib;virtual;
  50. procedure generatesmartlib;virtual;
  51. end;
  52. var
  53. importlib : timportlib;
  54. procedure InitImport;
  55. procedure DoneImport;
  56. implementation
  57. uses
  58. systems,verbose,globals
  59. {$ifdef i386}
  60. {$ifndef NOTARGETLINUX}
  61. ,t_linux
  62. {$endif}
  63. {$ifndef NOTARGETFREEBSD}
  64. ,t_fbsd
  65. {$endif}
  66. {$ifndef NOTARGETOS2}
  67. ,t_os2
  68. {$endif}
  69. {$ifndef NOTARGETWIN32}
  70. ,t_win32
  71. {$endif}
  72. {$ifndef NOTARGETNETWARE}
  73. ,t_nwm
  74. {$endif}
  75. {$ifndef NOTARGETGO32V2}
  76. ,t_go32v2
  77. {$endif}
  78. {$endif}
  79. {$ifdef m68k}
  80. {$ifndef NOTARGETLINUX}
  81. ,t_linux
  82. {$endif}
  83. {$endif}
  84. {$ifdef powerpc}
  85. {$ifndef NOTARGETLINUX}
  86. ,t_linux
  87. {$endif}
  88. {$endif}
  89. {$ifdef alpha}
  90. {$ifndef NOTARGETLINUX}
  91. ,t_linux
  92. {$endif}
  93. {$endif}
  94. ;
  95. {****************************************************************************
  96. Timported_item
  97. ****************************************************************************}
  98. constructor timported_item.Create(const n,s : string;o : word);
  99. begin
  100. inherited Create;
  101. func:=stringdup(n);
  102. name:=stringdup(s);
  103. ordnr:=o;
  104. lab:=nil;
  105. is_var:=false;
  106. end;
  107. constructor timported_item.create_var(const n,s : string);
  108. begin
  109. inherited Create;
  110. func:=stringdup(n);
  111. name:=stringdup(s);
  112. ordnr:=0;
  113. lab:=nil;
  114. is_var:=true;
  115. end;
  116. destructor timported_item.destroy;
  117. begin
  118. stringdispose(name);
  119. stringdispose(func);
  120. inherited destroy;
  121. end;
  122. {****************************************************************************
  123. TImportlist
  124. ****************************************************************************}
  125. constructor timportlist.Create(const n : string);
  126. begin
  127. inherited Create;
  128. dllname:=stringdup(n);
  129. imported_items:=Tlinkedlist.Create;
  130. end;
  131. destructor timportlist.destroy;
  132. begin
  133. imported_items.free;
  134. stringdispose(dllname);
  135. end;
  136. {****************************************************************************
  137. TImportLib
  138. ****************************************************************************}
  139. constructor timportlib.Create;
  140. begin
  141. notsupmsg:=false;
  142. end;
  143. destructor timportlib.Destroy;
  144. begin
  145. end;
  146. procedure timportlib.NotSupported;
  147. begin
  148. { show the message only once }
  149. if not notsupmsg then
  150. begin
  151. Message(exec_e_dll_not_supported);
  152. notsupmsg:=true;
  153. end;
  154. end;
  155. procedure timportlib.preparelib(const s:string);
  156. begin
  157. NotSupported;
  158. end;
  159. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  160. begin
  161. NotSupported;
  162. end;
  163. procedure timportlib.importvariable(const varname,module:string;const name:string);
  164. begin
  165. NotSupported;
  166. end;
  167. procedure timportlib.generatelib;
  168. begin
  169. NotSupported;
  170. end;
  171. procedure timportlib.generatesmartlib;
  172. begin
  173. NotSupported;
  174. end;
  175. procedure DoneImport;
  176. begin
  177. if assigned(importlib) then
  178. importlib.free;
  179. end;
  180. procedure InitImport;
  181. begin
  182. case target_info.target of
  183. {$ifdef i386}
  184. target_i386_Linux :
  185. importlib:=Timportliblinux.Create;
  186. target_i386_freebsd:
  187. importlib:=Timportlibfreebsd.Create;
  188. target_i386_Win32 :
  189. importlib:=Timportlibwin32.Create;
  190. target_i386_OS2 :
  191. importlib:=Timportlibos2.Create;
  192. target_i386_Netware :
  193. importlib:=Timportlibnetware.Create;
  194. {$endif i386}
  195. {$ifdef m68k}
  196. target_m68k_Linux :
  197. importlib:=Timportliblinux.Create;
  198. {$endif m68k}
  199. {$ifdef alpha}
  200. target_alpha_Linux :
  201. importlib:=Timportliblinux.Create;
  202. {$endif alpha}
  203. {$ifdef powerpc}
  204. target_alpha_Linux :
  205. importlib:=Timportliblinux.Create;
  206. {$endif powerpc}
  207. else
  208. importlib:=Timportlib.Create;
  209. end;
  210. end;
  211. end.
  212. {
  213. $Log$
  214. Revision 1.7 2000-12-25 00:07:26 peter
  215. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  216. tlinkedlist objects)
  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. }