gendef.pas 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. cclasses;
  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 : tstringlist;
  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:=TStringList.Create;
  53. exportlist:=TStringList.Create;
  54. end;
  55. destructor tdeffile.done;
  56. begin
  57. if WrittenOnDisk and
  58. not(cs_link_extern in aktglobalswitches) then
  59. DeleteFile(FName);
  60. importlist.Free;
  61. exportlist.Free;
  62. end;
  63. procedure tdeffile.addexport(const s:string);
  64. begin
  65. exportlist.insert(s);
  66. is_empty:=false;
  67. end;
  68. procedure tdeffile.addimport(const s:string);
  69. begin
  70. importlist.insert(s);
  71. is_empty:=false;
  72. end;
  73. function tdeffile.empty : boolean;
  74. begin
  75. empty:=is_empty and (description='');
  76. end;
  77. procedure tdeffile.writefile;
  78. var
  79. t : text;
  80. begin
  81. If WrittenOnDisk then
  82. Exit;
  83. { open file }
  84. assign(t,fname);
  85. {$I+}
  86. rewrite(t);
  87. {$I-}
  88. if ioresult<>0 then
  89. exit;
  90. {$ifdef i386}
  91. case target_info.target of
  92. target_i386_Os2 :
  93. begin
  94. write(t,'NAME '+inputfile);
  95. if usewindowapi then
  96. write(t,' WINDOWAPI');
  97. writeln(t,'');
  98. writeln(t,'PROTMODE');
  99. writeln(t,'DESCRIPTION '+''''+description+'''');
  100. writeln(t,'DATA'#9'MULTIPLE');
  101. writeln(t,'STACKSIZE'#9+tostr(stacksize));
  102. writeln(t,'HEAPSIZE'#9+tostr(heapsize));
  103. end;
  104. target_i386_win32 :
  105. begin
  106. if description<>'' then
  107. writeln(t,'DESCRIPTION '+''''+description+'''');
  108. if dllversion<>'' then
  109. writeln(t,'VERSION '+dllversion);
  110. end;
  111. end;
  112. {$endif}
  113. {write imports}
  114. if not importlist.empty then
  115. begin
  116. writeln(t,'');
  117. writeln(t,'IMPORTS');
  118. while not importlist.empty do
  119. writeln(t,#9+importlist.getfirst);
  120. end;
  121. {write exports}
  122. if not exportlist.empty then
  123. begin
  124. writeln(t,'');
  125. writeln(t,'EXPORTS');
  126. while not exportlist.empty do
  127. writeln(t,#9+exportlist.getfirst);
  128. end;
  129. close(t);
  130. WrittenOnDisk:=true;
  131. end;
  132. end.
  133. {
  134. $Log$
  135. Revision 1.5 2000-12-25 00:07:26 peter
  136. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  137. tlinkedlist objects)
  138. Revision 1.4 2000/09/24 15:06:16 peter
  139. * use defines.inc
  140. Revision 1.3 2000/08/27 16:11:50 peter
  141. * moved some util functions from globals,cobjects to cutils
  142. * splitted files into finput,fmodule
  143. Revision 1.2 2000/07/13 11:32:41 michael
  144. + removed logs
  145. }