export.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 : pshortstring;
  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. constructor Create;virtual;
  46. destructor Destroy;override;
  47. procedure preparelib(const s : string);virtual;
  48. procedure exportprocedure(hp : texported_item);virtual;
  49. procedure exportvar(hp : texported_item);virtual;
  50. procedure generatelib;virtual;
  51. end;
  52. TExportLibClass=class of TExportLib;
  53. var
  54. CExportLib : array[tsystem] of TExportLibClass;
  55. ExportLib : TExportLib;
  56. procedure RegisterExport(t:tsystem;c:TExportLibClass);
  57. procedure InitExport;
  58. procedure DoneExport;
  59. implementation
  60. uses
  61. verbose,globals;
  62. {****************************************************************************
  63. TExported_procedure
  64. ****************************************************************************}
  65. constructor texported_item.Create;
  66. begin
  67. inherited Create;
  68. sym:=nil;
  69. index:=-1;
  70. name:=nil;
  71. options:=0;
  72. is_var:=false;
  73. end;
  74. destructor texported_item.destroy;
  75. begin
  76. stringdispose(name);
  77. inherited destroy;
  78. end;
  79. {****************************************************************************
  80. TExportLib
  81. ****************************************************************************}
  82. constructor texportlib.Create;
  83. begin
  84. notsupmsg:=false;
  85. end;
  86. destructor texportlib.Destroy;
  87. begin
  88. end;
  89. procedure texportlib.NotSupported;
  90. begin
  91. { show the message only once }
  92. if not notsupmsg then
  93. begin
  94. Message(exec_e_dll_not_supported);
  95. notsupmsg:=true;
  96. end;
  97. end;
  98. procedure texportlib.preparelib(const s:string);
  99. begin
  100. NotSupported;
  101. end;
  102. procedure texportlib.exportprocedure(hp : texported_item);
  103. begin
  104. NotSupported;
  105. end;
  106. procedure texportlib.exportvar(hp : texported_item);
  107. begin
  108. NotSupported;
  109. end;
  110. procedure texportlib.generatelib;
  111. begin
  112. NotSupported;
  113. end;
  114. {*****************************************************************************
  115. Init/Done
  116. *****************************************************************************}
  117. procedure RegisterExport(t:tsystem;c:TExportLibClass);
  118. begin
  119. CExportLib[t]:=c;
  120. end;
  121. procedure InitExport;
  122. begin
  123. if assigned(CExportLib[target_info.system]) then
  124. exportlib:=CExportLib[target_info.system].Create
  125. else
  126. exportlib:=TExportLib.Create;
  127. end;
  128. procedure DoneExport;
  129. begin
  130. if assigned(Exportlib) then
  131. Exportlib.free;
  132. end;
  133. end.