import.pas 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 NOTARGETOS2}
  66. ,t_os2
  67. {$endif}
  68. {$ifndef NOTARGETWIN32}
  69. ,t_win32
  70. {$endif}
  71. {$ifndef NOTARGETNETWARE}
  72. ,t_nwm
  73. {$endif}
  74. {$ifndef NOTARGETGO32V2}
  75. ,t_go32v2
  76. {$endif}
  77. {$endif}
  78. {$ifdef m68k}
  79. {$ifndef NOTARGETLINUX}
  80. ,t_linux
  81. {$endif}
  82. {$endif}
  83. {$ifdef powerpc}
  84. {$ifndef NOTARGETLINUX}
  85. ,t_linux
  86. {$endif}
  87. {$endif}
  88. {$ifdef alpha}
  89. {$ifndef NOTARGETLINUX}
  90. ,t_linux
  91. {$endif}
  92. {$endif}
  93. ;
  94. {****************************************************************************
  95. Timported_item
  96. ****************************************************************************}
  97. constructor timported_item.init(const n,s : string;o : word);
  98. begin
  99. inherited init;
  100. func:=stringdup(n);
  101. name:=stringdup(s);
  102. ordnr:=o;
  103. lab:=nil;
  104. is_var:=false;
  105. end;
  106. constructor timported_item.init_var(const n,s : string);
  107. begin
  108. inherited init;
  109. func:=stringdup(n);
  110. name:=stringdup(s);
  111. ordnr:=0;
  112. lab:=nil;
  113. is_var:=true;
  114. end;
  115. destructor timported_item.done;
  116. begin
  117. stringdispose(name);
  118. stringdispose(func);
  119. inherited done;
  120. end;
  121. {****************************************************************************
  122. TImportlist
  123. ****************************************************************************}
  124. constructor timportlist.init(const n : string);
  125. begin
  126. inherited init;
  127. dllname:=stringdup(n);
  128. imported_items:=new(plinkedlist,init);
  129. end;
  130. destructor timportlist.done;
  131. begin
  132. dispose(imported_items,done);
  133. stringdispose(dllname);
  134. end;
  135. {****************************************************************************
  136. TImportLib
  137. ****************************************************************************}
  138. constructor timportlib.Init;
  139. begin
  140. notsupmsg:=false;
  141. end;
  142. destructor timportlib.Done;
  143. begin
  144. end;
  145. procedure timportlib.NotSupported;
  146. begin
  147. { show the message only once }
  148. if not notsupmsg then
  149. begin
  150. Message(exec_e_dll_not_supported);
  151. notsupmsg:=true;
  152. end;
  153. end;
  154. procedure timportlib.preparelib(const s:string);
  155. begin
  156. NotSupported;
  157. end;
  158. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  159. begin
  160. NotSupported;
  161. end;
  162. procedure timportlib.importvariable(const varname,module:string;const name:string);
  163. begin
  164. NotSupported;
  165. end;
  166. procedure timportlib.generatelib;
  167. begin
  168. NotSupported;
  169. end;
  170. procedure timportlib.generatesmartlib;
  171. begin
  172. NotSupported;
  173. end;
  174. procedure DoneImport;
  175. begin
  176. if assigned(importlib) then
  177. dispose(importlib,done);
  178. end;
  179. procedure InitImport;
  180. begin
  181. case target_info.target of
  182. {$ifdef i386}
  183. target_i386_Linux :
  184. importlib:=new(pimportliblinux,Init);
  185. target_i386_Win32 :
  186. importlib:=new(pimportlibwin32,Init);
  187. target_i386_OS2 :
  188. importlib:=new(pimportlibos2,Init);
  189. target_i386_Netware :
  190. importlib:=new(pimportlibnetware,Init);
  191. {$endif i386}
  192. {$ifdef m68k}
  193. target_m68k_Linux :
  194. importlib:=new(pimportliblinux,Init);
  195. {$endif m68k}
  196. {$ifdef alpha}
  197. target_alpha_Linux :
  198. importlib:=new(pimportliblinux,Init);
  199. {$endif alpha}
  200. {$ifdef powerpc}
  201. target_alpha_Linux :
  202. importlib:=new(pimportliblinux,Init);
  203. {$endif powerpc}
  204. else
  205. importlib:=new(pimportlib,Init);
  206. end;
  207. end;
  208. end.
  209. {
  210. $Log$
  211. Revision 1.4 2000-09-11 17:00:23 florian
  212. + first implementation of Netware Module support, thanks to
  213. Armin Diehl ([email protected]) for providing the patches
  214. Revision 1.3 2000/08/27 16:11:51 peter
  215. * moved some util functions from globals,cobjects to cutils
  216. * splitted files into finput,fmodule
  217. Revision 1.2 2000/07/13 11:32:43 michael
  218. + removed logs
  219. }