gendef.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Generation of a .def file for needed for Os2/Win32
  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 gendef;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. cobjects;
  23. type
  24. pdeffile=^tdeffile;
  25. tdeffile=object
  26. fname : string;
  27. constructor init(const fn:string);
  28. destructor done;
  29. procedure addexport(const s:string);
  30. procedure addimport(const s:string);
  31. procedure writefile;
  32. function empty : boolean;
  33. private
  34. is_empty : boolean;
  35. WrittenOnDisk : boolean;
  36. exportlist,
  37. importlist : tstringcontainer;
  38. end;
  39. var
  40. deffile : tdeffile;
  41. implementation
  42. uses
  43. systems,cutils,globtype,globals;
  44. {******************************************************************************
  45. TDefFile
  46. ******************************************************************************}
  47. constructor tdeffile.init(const fn:string);
  48. begin
  49. fname:=fn;
  50. WrittenOnDisk:=false;
  51. is_empty:=true;
  52. importlist.init;
  53. exportlist.init;
  54. end;
  55. destructor tdeffile.done;
  56. var
  57. f : file;
  58. begin
  59. if WrittenOnDisk and
  60. not(cs_link_extern in aktglobalswitches) then
  61. begin
  62. assign(f,fname);
  63. {$I-}
  64. erase(f);
  65. {$I+}
  66. if ioresult<>0 then;
  67. end;
  68. importlist.done;
  69. exportlist.done;
  70. end;
  71. procedure tdeffile.addexport(const s:string);
  72. begin
  73. exportlist.insert(s);
  74. is_empty:=false;
  75. end;
  76. procedure tdeffile.addimport(const s:string);
  77. begin
  78. importlist.insert(s);
  79. is_empty:=false;
  80. end;
  81. function tdeffile.empty : boolean;
  82. begin
  83. empty:=is_empty and (description='');
  84. end;
  85. procedure tdeffile.writefile;
  86. var
  87. t : text;
  88. begin
  89. If WrittenOnDisk then
  90. Exit;
  91. { open file }
  92. assign(t,fname);
  93. {$I+}
  94. rewrite(t);
  95. {$I-}
  96. if ioresult<>0 then
  97. exit;
  98. {$ifdef i386}
  99. case target_info.target of
  100. target_i386_Os2 :
  101. begin
  102. write(t,'NAME '+inputfile);
  103. if usewindowapi then
  104. write(t,' WINDOWAPI');
  105. writeln(t,'');
  106. writeln(t,'PROTMODE');
  107. writeln(t,'DESCRIPTION '+''''+description+'''');
  108. writeln(t,'DATA'#9'MULTIPLE');
  109. writeln(t,'STACKSIZE'#9+tostr(stacksize));
  110. writeln(t,'HEAPSIZE'#9+tostr(heapsize));
  111. end;
  112. target_i386_win32 :
  113. begin
  114. if description<>'' then
  115. writeln(t,'DESCRIPTION '+''''+description+'''');
  116. if dllversion<>'' then
  117. writeln(t,'VERSION '+dllversion);
  118. end;
  119. end;
  120. {$endif}
  121. {write imports}
  122. if not importlist.empty then
  123. begin
  124. writeln(t,'');
  125. writeln(t,'IMPORTS');
  126. while not importlist.empty do
  127. writeln(t,#9+importlist.get);
  128. end;
  129. {write exports}
  130. if not exportlist.empty then
  131. begin
  132. writeln(t,'');
  133. writeln(t,'EXPORTS');
  134. while not exportlist.empty do
  135. writeln(t,#9+exportlist.get);
  136. end;
  137. close(t);
  138. WrittenOnDisk:=true;
  139. end;
  140. end.
  141. {
  142. $Log$
  143. Revision 1.4 2000-09-24 15:06:16 peter
  144. * use defines.inc
  145. Revision 1.3 2000/08/27 16:11:50 peter
  146. * moved some util functions from globals,cobjects to cutils
  147. * splitted files into finput,fmodule
  148. Revision 1.2 2000/07/13 11:32:41 michael
  149. + removed logs
  150. }