import.pas 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. os2_targ,win_targ;
  52. {****************************************************************************
  53. TImported_procedure
  54. ****************************************************************************}
  55. constructor timported_procedure.init(const n,s : string;o : word);
  56. begin
  57. inherited init;
  58. func:=stringdup(n);
  59. name:=stringdup(s);
  60. ordnr:=o;
  61. lab:=nil;
  62. end;
  63. destructor timported_procedure.done;
  64. begin
  65. stringdispose(name);
  66. inherited done;
  67. end;
  68. {****************************************************************************
  69. TImportlist
  70. ****************************************************************************}
  71. constructor timportlist.init(const n : string);
  72. begin
  73. inherited init;
  74. dllname:=stringdup(n);
  75. imported_procedures:=new(plinkedlist,init);
  76. end;
  77. destructor timportlist.done;
  78. begin
  79. dispose(imported_procedures,done);
  80. stringdispose(dllname);
  81. end;
  82. {****************************************************************************
  83. TImportLib
  84. ****************************************************************************}
  85. constructor timportlib.Init;
  86. begin
  87. end;
  88. destructor timportlib.Done;
  89. begin
  90. end;
  91. procedure timportlib.preparelib(const s:string);
  92. begin
  93. Message(exec_e_dll_not_supported);
  94. end;
  95. procedure timportlib.importprocedure(const func,module:string;index:longint;const name:string);
  96. begin
  97. Message(exec_e_dll_not_supported);
  98. end;
  99. procedure timportlib.generatelib;
  100. begin
  101. Message(exec_e_dll_not_supported);
  102. end;
  103. procedure InitImport;
  104. begin
  105. case target_info.target of
  106. target_Win32 : importlib:=new(pimportlibwin32,Init);
  107. target_OS2 : importlib:=new(pimportlibos2,Init);
  108. else
  109. importlib:=new(pimportlib,Init);
  110. end;
  111. end;
  112. end.
  113. {
  114. $Log$
  115. Revision 1.2 1998-04-27 23:10:28 peter
  116. + new scanner
  117. * $makelib -> if smartlink
  118. * small filename fixes pmodule.setfilename
  119. * moved import from files.pas -> import.pas
  120. Revision 1.1.1.1 1998/03/25 11:18:12 root
  121. * Restored version
  122. Revision 1.3 1998/03/10 01:17:19 peter
  123. * all files have the same header
  124. * messages are fully implemented, EXTDEBUG uses Comment()
  125. + AG... files for the Assembler generation
  126. Revision 1.2 1998/03/06 00:52:21 peter
  127. * replaced all old messages from errore.msg, only ExtDebug and some
  128. Comment() calls are left
  129. * fixed options.pas
  130. }