import.pas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Peter Vreman
  4. This unit implements an uniform import 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. unit import;
  18. interface
  19. uses
  20. cobjects;
  21. type
  22. pimported_procedure = ^timported_procedure;
  23. timported_procedure = object(tlinkedlist_item)
  24. ordnr : word;
  25. name,func : pstring;
  26. lab : pointer; { should be plabel, but this gaves problems with circular units }
  27. constructor init(const n,s : string;o : word);
  28. destructor done;virtual;
  29. end;
  30. pimportlist = ^timportlist;
  31. timportlist = object(tlinkedlist_item)
  32. dllname : pstring;
  33. imported_procedures : plinkedlist;
  34. constructor init(const n : string);
  35. destructor done;virtual;
  36. end;
  37. pimportlib=^timportlib;
  38. timportlib=object
  39. constructor Init;
  40. destructor Done;
  41. procedure preparelib(const s:string);virtual;
  42. procedure importprocedure(const func,module:string;index:longint;const name:string);virtual;
  43. procedure generatelib;virtual;
  44. end;
  45. var
  46. importlib : pimportlib;
  47. procedure InitImport;
  48. implementation
  49. uses
  50. systems,verbose
  51. {$ifdef i386}
  52. ,os2_targ
  53. ,win_targ
  54. {$endif}
  55. ;
  56. {****************************************************************************
  57. TImported_procedure
  58. ****************************************************************************}
  59. constructor timported_procedure.init(const n,s : string;o : word);
  60. begin
  61. inherited init;
  62. func:=stringdup(n);
  63. name:=stringdup(s);
  64. ordnr:=o;
  65. lab:=nil;
  66. end;
  67. destructor timported_procedure.done;
  68. begin
  69. stringdispose(name);
  70. inherited done;
  71. end;
  72. {****************************************************************************
  73. TImportlist
  74. ****************************************************************************}
  75. constructor timportlist.init(const n : string);
  76. begin
  77. inherited init;
  78. dllname:=stringdup(n);
  79. imported_procedures:=new(plinkedlist,init);
  80. end;
  81. destructor timportlist.done;
  82. begin
  83. dispose(imported_procedures,done);
  84. stringdispose(dllname);
  85. end;
  86. {****************************************************************************
  87. TImportLib
  88. ****************************************************************************}
  89. constructor timportlib.Init;
  90. begin
  91. end;
  92. destructor timportlib.Done;
  93. begin
  94. end;
  95. procedure timportlib.preparelib(const s:string);
  96. begin
  97. Message(exec_e_dll_not_supported);
  98. end;
  99. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  100. begin
  101. Message(exec_e_dll_not_supported);
  102. end;
  103. procedure timportlib.generatelib;
  104. begin
  105. Message(exec_e_dll_not_supported);
  106. end;
  107. procedure InitImport;
  108. begin
  109. {$ifdef i386}
  110. case target_info.target of
  111. target_Win32 : importlib:=new(pimportlibwin32,Init);
  112. target_OS2 : importlib:=new(pimportlibos2,Init);
  113. else
  114. importlib:=new(pimportlib,Init);
  115. end;
  116. {$endif i386}
  117. {$ifdef m68k}
  118. importlib:=new(pimportlib,Init);
  119. {$endif m68k}
  120. end;
  121. end.
  122. {
  123. $Log$
  124. Revision 1.3 1998-06-04 23:51:43 peter
  125. * m68k compiles
  126. + .def file creation moved to gendef.pas so it could also be used
  127. for win32
  128. Revision 1.2 1998/04/27 23:10:28 peter
  129. + new scanner
  130. * $makelib -> if smartlink
  131. * small filename fixes pmodule.setfilename
  132. * moved import from files.pas -> import.pas
  133. Revision 1.1.1.1 1998/03/25 11:18:12 root
  134. * Restored version
  135. Revision 1.3 1998/03/10 01:17:19 peter
  136. * all files have the same header
  137. * messages are fully implemented, EXTDEBUG uses Comment()
  138. + AG... files for the Assembler generation
  139. Revision 1.2 1998/03/06 00:52:21 peter
  140. * replaced all old messages from errore.msg, only ExtDebug and some
  141. Comment() calls are left
  142. * fixed options.pas
  143. }