export.pas 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cutils,cclasses,
  23. systems,
  24. symtype,
  25. aasmbase;
  26. const
  27. { export options }
  28. eo_resident = $1;
  29. eo_index = $2;
  30. eo_name = $4;
  31. type
  32. texported_item = class(TLinkedListItem)
  33. sym : tsym;
  34. index : longint;
  35. name : pstring;
  36. options : word;
  37. is_var : boolean;
  38. constructor create;
  39. destructor destroy;override;
  40. end;
  41. texportlib=class
  42. private
  43. notsupmsg : boolean;
  44. procedure NotSupported;
  45. public
  46. edatalabel : tasmlabel;
  47. constructor Create;virtual;
  48. destructor Destroy;override;
  49. procedure preparelib(const s : string);virtual;
  50. procedure exportprocedure(hp : texported_item);virtual;
  51. procedure exportvar(hp : texported_item);virtual;
  52. procedure generatelib;virtual;
  53. end;
  54. TExportLibClass=class of TExportLib;
  55. var
  56. CExportLib : array[tsystem] of TExportLibClass;
  57. ExportLib : TExportLib;
  58. procedure RegisterExport(t:tsystem;c:TExportLibClass);
  59. procedure InitExport;
  60. procedure DoneExport;
  61. implementation
  62. uses
  63. verbose,globals;
  64. {****************************************************************************
  65. TExported_procedure
  66. ****************************************************************************}
  67. constructor texported_item.Create;
  68. begin
  69. inherited Create;
  70. sym:=nil;
  71. index:=-1;
  72. name:=nil;
  73. options:=0;
  74. is_var:=false;
  75. end;
  76. destructor texported_item.destroy;
  77. begin
  78. stringdispose(name);
  79. inherited destroy;
  80. end;
  81. {****************************************************************************
  82. TExportLib
  83. ****************************************************************************}
  84. constructor texportlib.Create;
  85. begin
  86. notsupmsg:=false;
  87. edatalabel:=nil;
  88. end;
  89. destructor texportlib.Destroy;
  90. begin
  91. end;
  92. procedure texportlib.NotSupported;
  93. begin
  94. { show the message only once }
  95. if not notsupmsg then
  96. begin
  97. Message(exec_e_dll_not_supported);
  98. notsupmsg:=true;
  99. end;
  100. end;
  101. procedure texportlib.preparelib(const s:string);
  102. begin
  103. NotSupported;
  104. end;
  105. procedure texportlib.exportprocedure(hp : texported_item);
  106. begin
  107. NotSupported;
  108. end;
  109. procedure texportlib.exportvar(hp : texported_item);
  110. begin
  111. NotSupported;
  112. end;
  113. procedure texportlib.generatelib;
  114. begin
  115. NotSupported;
  116. end;
  117. {*****************************************************************************
  118. Init/Done
  119. *****************************************************************************}
  120. procedure RegisterExport(t:tsystem;c:TExportLibClass);
  121. begin
  122. CExportLib[t]:=c;
  123. end;
  124. procedure InitExport;
  125. begin
  126. if assigned(CExportLib[target_info.system]) then
  127. exportlib:=CExportLib[target_info.system].Create
  128. else
  129. exportlib:=TExportLib.Create;
  130. end;
  131. procedure DoneExport;
  132. begin
  133. if assigned(Exportlib) then
  134. Exportlib.free;
  135. end;
  136. end.
  137. {
  138. $Log$
  139. Revision 1.21 2002-07-26 21:15:37 florian
  140. * rewrote the system handling
  141. Revision 1.20 2002/07/01 18:46:22 peter
  142. * internal linker
  143. * reorganized aasm layer
  144. Revision 1.19 2002/05/18 13:34:07 peter
  145. * readded missing revisions
  146. Revision 1.18 2002/05/16 19:46:36 carl
  147. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  148. + try to fix temp allocation (still in ifdef)
  149. + generic constructor calls
  150. + start of tassembler / tmodulebase class cleanup
  151. }