export.pas 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This unit implements an uniform export 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. }
  18. unit export;
  19. interface
  20. uses
  21. cobjects{$IFDEF NEWST},objects{$ENDIF NEWST},symtable;
  22. const
  23. { export options }
  24. eo_resident = $1;
  25. eo_index = $2;
  26. eo_name = $4;
  27. type
  28. pexported_item = ^texported_item;
  29. texported_item = object(tlinkedlist_item)
  30. sym : psym;
  31. index : longint;
  32. name : pstring;
  33. options : word;
  34. is_var : boolean;
  35. constructor init;
  36. destructor done;virtual;
  37. end;
  38. pexportlib=^texportlib;
  39. texportlib=object
  40. private
  41. notsupmsg : boolean;
  42. procedure NotSupported;
  43. public
  44. constructor Init;
  45. destructor Done;
  46. procedure preparelib(const s : string);virtual;
  47. procedure exportprocedure(hp : pexported_item);virtual;
  48. procedure exportvar(hp : pexported_item);virtual;
  49. procedure generatelib;virtual;
  50. end;
  51. var
  52. exportlib : pexportlib;
  53. procedure InitExport;
  54. procedure DoneExport;
  55. implementation
  56. uses
  57. systems,verbose,globals,files
  58. {$ifdef i386}
  59. {$ifndef NOTARGETLINUX}
  60. ,t_linux
  61. {$endif}
  62. {$ifndef NOTARGETOS2}
  63. ,t_os2
  64. {$endif}
  65. {$ifndef NOTARGETWIN32}
  66. ,t_win32
  67. {$endif}
  68. {$ifndef NOTARGETGO32V2}
  69. ,t_go32v2
  70. {$endif}
  71. {$endif}
  72. {$ifdef m68k}
  73. {$ifndef NOTARGETLINUX}
  74. ,t_linux
  75. {$endif}
  76. {$endif}
  77. {$ifdef powerpc}
  78. {$ifndef NOTARGETLINUX}
  79. ,t_linux
  80. {$endif}
  81. {$endif}
  82. {$ifdef alpha}
  83. {$ifndef NOTARGETLINUX}
  84. ,t_linux
  85. {$endif}
  86. {$endif}
  87. ;
  88. {****************************************************************************
  89. TImported_procedure
  90. ****************************************************************************}
  91. constructor texported_item.init;
  92. begin
  93. inherited init;
  94. sym:=nil;
  95. index:=-1;
  96. name:=nil;
  97. options:=0;
  98. is_var:=false;
  99. end;
  100. destructor texported_item.done;
  101. begin
  102. stringdispose(name);
  103. inherited done;
  104. end;
  105. {****************************************************************************
  106. TImportLib
  107. ****************************************************************************}
  108. constructor texportlib.Init;
  109. begin
  110. notsupmsg:=false;
  111. end;
  112. destructor texportlib.Done;
  113. begin
  114. end;
  115. procedure texportlib.NotSupported;
  116. begin
  117. { show the message only once }
  118. if not notsupmsg then
  119. begin
  120. Message(exec_e_dll_not_supported);
  121. notsupmsg:=true;
  122. end;
  123. end;
  124. procedure texportlib.preparelib(const s:string);
  125. begin
  126. NotSupported;
  127. end;
  128. procedure texportlib.exportprocedure(hp : pexported_item);
  129. begin
  130. NotSupported;
  131. end;
  132. procedure texportlib.exportvar(hp : pexported_item);
  133. begin
  134. NotSupported;
  135. end;
  136. procedure texportlib.generatelib;
  137. begin
  138. NotSupported;
  139. end;
  140. procedure DoneExport;
  141. begin
  142. if assigned(exportlib) then
  143. dispose(exportlib,done);
  144. end;
  145. procedure InitExport;
  146. begin
  147. case target_info.target of
  148. {$ifdef i386}
  149. target_i386_Linux :
  150. exportlib:=new(pexportliblinux,Init);
  151. target_i386_Win32 :
  152. exportlib:=new(pexportlibwin32,Init);
  153. {
  154. target_i386_OS2 :
  155. exportlib:=new(pexportlibos2,Init);
  156. }
  157. {$endif i386}
  158. {$ifdef m68k}
  159. target_m68k_Linux :
  160. exportlib:=new(pexportlib,Init);
  161. {$endif m68k}
  162. {$ifdef alpha}
  163. target_alpha_Linux :
  164. exportlib:=new(pexportlib,Init);
  165. {$endif alpha}
  166. {$ifdef powerpc}
  167. target_alpha_Linux :
  168. exportlib:=new(pexportlib,Init);
  169. {$endif powerpc}
  170. else
  171. exportlib:=new(pexportlib,Init);
  172. end;
  173. end;
  174. end.
  175. {
  176. $Log$
  177. Revision 1.12 2000-02-28 17:23:56 daniel
  178. * Current work of symtable integration committed. The symtable can be
  179. activated by defining 'newst', but doesn't compile yet. Changes in type
  180. checking and oop are completed. What is left is to write a new
  181. symtablestack and adapt the parser to use it.
  182. Revision 1.11 2000/02/09 13:22:52 peter
  183. * log truncated
  184. Revision 1.10 2000/01/12 10:34:29 peter
  185. * only give unsupported error once
  186. Revision 1.9 2000/01/07 01:14:27 peter
  187. * updated copyright to 2000
  188. Revision 1.8 1999/11/06 14:34:20 peter
  189. * truncated log to 20 revs
  190. Revision 1.7 1999/10/21 14:29:34 peter
  191. * redesigned linker object
  192. + library support for linux (only procedures can be exported)
  193. Revision 1.6 1999/08/04 13:02:41 jonas
  194. * all tokens now start with an underscore
  195. * PowerPC compiles!!
  196. Revision 1.5 1999/08/03 17:09:34 florian
  197. * the alpha compiler can be compiled now
  198. }