gobject-generate-headers.pl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/usr/bin/perl -w
  2. #
  3. # Copyright (C) 2009 Adam Dingle <adam@yorba.org>
  4. #
  5. # This file is part of WebKit
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Library General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Library General Public License
  18. # aint with this library; see the file COPYING.LIB. If not, write to
  19. # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. # Boston, MA 02110-1301, USA.
  21. #
  22. my $classlist = <STDIN>;
  23. chomp($classlist);
  24. my @classes = split / /, $classlist;
  25. @classes = sort @classes;
  26. print <<EOF;
  27. /* This file is part of the WebKit open source project.
  28. This file has been generated by gobject-generate-headers.pl. DO NOT MODIFY!
  29. This library is free software; you can redistribute it and/or
  30. modify it under the terms of the GNU Library General Public
  31. License as published by the Free Software Foundation; either
  32. version 2 of the License, or (at your option) any later version.
  33. This library is distributed in the hope that it will be useful,
  34. but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  36. Library General Public License for more details.
  37. You should have received a copy of the GNU Library General Public License
  38. along with this library; see the file COPYING.LIB. If not, write to
  39. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  40. Boston, MA 02110-1301, USA.
  41. */
  42. EOF
  43. my $outType = $ARGV[0];
  44. my $header;
  45. if ($outType eq "defines") {
  46. $header = "webkitdomdefines_h";
  47. } elsif ($outType eq "gdom") {
  48. $header = "webkitdom_h";
  49. } else {
  50. die "unknown output type";
  51. }
  52. print "#ifndef ${header}\n";
  53. print "#define ${header}\n";
  54. print "\n";
  55. if ($outType eq "defines") {
  56. print "#include <glib.h>\n\n";
  57. print "#ifdef G_OS_WIN32\n";
  58. print " #ifdef BUILDING_WEBKIT\n";
  59. print " #define WEBKIT_API __declspec(dllexport)\n";
  60. print " #else\n";
  61. print " #define WEBKIT_API __declspec(dllimport)\n";
  62. print " #endif\n";
  63. print " #define WEBKIT_OBSOLETE_API WEBKIT_API\n";
  64. print "#else\n";
  65. print " #define WEBKIT_API __attribute__((visibility(\"default\")))\n";
  66. print " #define WEBKIT_OBSOLETE_API WEBKIT_API __attribute__((deprecated))\n";
  67. print "#endif\n\n";
  68. print "#ifndef WEBKIT_API\n";
  69. print " #define WEBKIT_API\n";
  70. print "#endif\n";
  71. foreach my $class (@classes) {
  72. print "typedef struct _WebKitDOM${class} WebKitDOM${class};\n";
  73. print "typedef struct _WebKitDOM${class}Class WebKitDOM${class}Class;\n";
  74. print "\n";
  75. }
  76. } elsif ($outType eq "gdom") {
  77. print "#define __WEBKITDOM_H_INSIDE__\n\n";
  78. foreach my $class (@classes) {
  79. print "#include <webkitdom/WebKitDOM${class}.h>\n";
  80. }
  81. print "\n#undef __WEBKITDOM_H_INSIDE__\n";
  82. }
  83. print "\n";
  84. print "#endif\n";