export.pas 5.0 KB

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