export.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements an uniform export object
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit export;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cutils,cclasses,
  22. systems,
  23. symtype,
  24. aasmbase;
  25. const
  26. { export options }
  27. eo_resident = $1;
  28. eo_index = $2;
  29. eo_name = $4;
  30. type
  31. texported_item = class(TLinkedListItem)
  32. sym : tsym;
  33. index : longint;
  34. name : pstring;
  35. options : word;
  36. is_var : boolean;
  37. constructor create;
  38. destructor destroy;override;
  39. end;
  40. texportlib=class
  41. private
  42. notsupmsg : boolean;
  43. procedure NotSupported;
  44. public
  45. edatalabel : tasmlabel;
  46. constructor Create;virtual;
  47. destructor Destroy;override;
  48. procedure preparelib(const s : string);virtual;
  49. procedure exportprocedure(hp : texported_item);virtual;
  50. procedure exportvar(hp : texported_item);virtual;
  51. procedure generatelib;virtual;
  52. end;
  53. TExportLibClass=class of TExportLib;
  54. var
  55. CExportLib : array[tsystem] of TExportLibClass;
  56. ExportLib : TExportLib;
  57. procedure RegisterExport(t:tsystem;c:TExportLibClass);
  58. procedure InitExport;
  59. procedure DoneExport;
  60. implementation
  61. uses
  62. verbose,globals;
  63. {****************************************************************************
  64. TExported_procedure
  65. ****************************************************************************}
  66. constructor texported_item.Create;
  67. begin
  68. inherited Create;
  69. sym:=nil;
  70. index:=-1;
  71. name:=nil;
  72. options:=0;
  73. is_var:=false;
  74. end;
  75. destructor texported_item.destroy;
  76. begin
  77. stringdispose(name);
  78. inherited destroy;
  79. end;
  80. {****************************************************************************
  81. TExportLib
  82. ****************************************************************************}
  83. constructor texportlib.Create;
  84. begin
  85. notsupmsg:=false;
  86. edatalabel:=nil;
  87. end;
  88. destructor texportlib.Destroy;
  89. begin
  90. end;
  91. procedure texportlib.NotSupported;
  92. begin
  93. { show the message only once }
  94. if not notsupmsg then
  95. begin
  96. Message(exec_e_dll_not_supported);
  97. notsupmsg:=true;
  98. end;
  99. end;
  100. procedure texportlib.preparelib(const s:string);
  101. begin
  102. NotSupported;
  103. end;
  104. procedure texportlib.exportprocedure(hp : texported_item);
  105. begin
  106. NotSupported;
  107. end;
  108. procedure texportlib.exportvar(hp : texported_item);
  109. begin
  110. NotSupported;
  111. end;
  112. procedure texportlib.generatelib;
  113. begin
  114. NotSupported;
  115. end;
  116. {*****************************************************************************
  117. Init/Done
  118. *****************************************************************************}
  119. procedure RegisterExport(t:tsystem;c:TExportLibClass);
  120. begin
  121. CExportLib[t]:=c;
  122. end;
  123. procedure InitExport;
  124. begin
  125. if assigned(CExportLib[target_info.system]) then
  126. exportlib:=CExportLib[target_info.system].Create
  127. else
  128. exportlib:=TExportLib.Create;
  129. end;
  130. procedure DoneExport;
  131. begin
  132. if assigned(Exportlib) then
  133. Exportlib.free;
  134. end;
  135. end.