export.pas 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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,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. constructor Init;
  41. destructor Done;
  42. procedure preparelib(const s : string);virtual;
  43. procedure exportprocedure(hp : pexported_item);virtual;
  44. procedure exportvar(hp : pexported_item);virtual;
  45. procedure generatelib;virtual;
  46. end;
  47. var
  48. exportlib : pexportlib;
  49. procedure InitExport;
  50. procedure DoneExport;
  51. implementation
  52. uses
  53. systems,verbose,globals,files
  54. {$ifdef i386}
  55. {$ifndef NOTARGETLINUX}
  56. ,t_linux
  57. {$endif}
  58. {$ifndef NOTARGETOS2}
  59. ,t_os2
  60. {$endif}
  61. {$ifndef NOTARGETWIN32}
  62. ,t_win32
  63. {$endif}
  64. {$ifndef NOTARGETGO32V2}
  65. ,t_go32v2
  66. {$endif}
  67. {$endif}
  68. {$ifdef m68k}
  69. {$ifndef NOTARGETLINUX}
  70. ,t_linux
  71. {$endif}
  72. {$endif}
  73. {$ifdef powerpc}
  74. {$ifndef NOTARGETLINUX}
  75. ,t_linux
  76. {$endif}
  77. {$endif}
  78. {$ifdef alpha}
  79. {$ifndef NOTARGETLINUX}
  80. ,t_linux
  81. {$endif}
  82. {$endif}
  83. ;
  84. {****************************************************************************
  85. TImported_procedure
  86. ****************************************************************************}
  87. constructor texported_item.init;
  88. begin
  89. inherited init;
  90. sym:=nil;
  91. index:=-1;
  92. name:=nil;
  93. options:=0;
  94. is_var:=false;
  95. end;
  96. destructor texported_item.done;
  97. begin
  98. stringdispose(name);
  99. inherited done;
  100. end;
  101. {****************************************************************************
  102. TImportLib
  103. ****************************************************************************}
  104. constructor texportlib.Init;
  105. begin
  106. end;
  107. destructor texportlib.Done;
  108. begin
  109. end;
  110. procedure texportlib.preparelib(const s:string);
  111. begin
  112. Message(exec_e_dll_not_supported);
  113. end;
  114. procedure texportlib.exportprocedure(hp : pexported_item);
  115. begin
  116. Message(exec_e_dll_not_supported);
  117. end;
  118. procedure texportlib.exportvar(hp : pexported_item);
  119. begin
  120. Message(exec_e_dll_not_supported);
  121. end;
  122. procedure texportlib.generatelib;
  123. begin
  124. Message(exec_e_dll_not_supported);
  125. end;
  126. procedure DoneExport;
  127. begin
  128. if assigned(exportlib) then
  129. dispose(exportlib,done);
  130. end;
  131. procedure InitExport;
  132. begin
  133. case target_info.target of
  134. {$ifdef i386}
  135. target_i386_Linux :
  136. exportlib:=new(pexportliblinux,Init);
  137. target_i386_Win32 :
  138. exportlib:=new(pexportlibwin32,Init);
  139. {
  140. target_i386_OS2 :
  141. exportlib:=new(pexportlibos2,Init);
  142. }
  143. {$endif i386}
  144. {$ifdef m68k}
  145. target_m68k_Linux :
  146. exportlib:=new(pexportlib,Init);
  147. {$endif m68k}
  148. {$ifdef alpha}
  149. target_alpha_Linux :
  150. exportlib:=new(pexportlib,Init);
  151. {$endif alpha}
  152. {$ifdef powerpc}
  153. target_alpha_Linux :
  154. exportlib:=new(pexportlib,Init);
  155. {$endif powerpc}
  156. else
  157. exportlib:=new(pexportlib,Init);
  158. end;
  159. end;
  160. end.
  161. {
  162. $Log$
  163. Revision 1.9 2000-01-07 01:14:27 peter
  164. * updated copyright to 2000
  165. Revision 1.8 1999/11/06 14:34:20 peter
  166. * truncated log to 20 revs
  167. Revision 1.7 1999/10/21 14:29:34 peter
  168. * redesigned linker object
  169. + library support for linux (only procedures can be exported)
  170. Revision 1.6 1999/08/04 13:02:41 jonas
  171. * all tokens now start with an underscore
  172. * PowerPC compiles!!
  173. Revision 1.5 1999/08/03 17:09:34 florian
  174. * the alpha compiler can be compiled now
  175. Revision 1.4 1998/11/30 09:43:09 pierre
  176. * some range check bugs fixed (still not working !)
  177. + added DLL writing support for win32 (also accepts variables)
  178. + TempAnsi for code that could be used for Temporary ansi strings
  179. handling
  180. Revision 1.3 1998/11/16 11:28:57 pierre
  181. * stackcheck removed for i386_win32
  182. * exportlist does not crash at least !!
  183. (was need for tests dir !)z
  184. Revision 1.2 1998/10/29 11:35:43 florian
  185. * some dll support for win32
  186. * fixed assembler writing for PalmOS
  187. Revision 1.1 1998/10/27 10:22:34 florian
  188. + First things for win32 export sections
  189. }