logo

libbulletml

Library of Bullet Markup Language (forked from https://shinh.skr.jp/libbulletml/index_en.html )git clone https://hacktivis.me/git/libbulletml.git

create_d_cpp_interface.pl (2991B)


  1. use strict;
  2. print "#define D_CPP_CLASS(CLASS, CLASS_NAME) ;\n";
  3. print "\n";
  4. for (my $i = 0; $i < 10; $i++) {
  5. print "#define D_CPP_NEW_$i(CLASS, NEW_NAME";
  6. my @args;
  7. my @args2;
  8. for (my $j = 1; $j <= $i; $j++) {
  9. print ", ARG$j";
  10. push @args, "ARG$j arg$j";
  11. push @args2, "arg$j";
  12. }
  13. print ") \\\n";
  14. my $argStr = join ', ', @args;
  15. my $argStr2 = join ', ', @args2;
  16. print "CLASS* NEW_NAME($argStr) { \\\n";
  17. print " return new CLASS($argStr2); \\\n";
  18. print "}\n";
  19. print "\n";
  20. }
  21. print "#define D_CPP_DELETE(CLASS, DELETE_NAME) \\\n";
  22. print "void DELETE_NAME(CLASS* c) { delete c; } \n";
  23. print "\n";
  24. for (my $i = 0; $i < 10; $i++) {
  25. print "#define D_CPP_METHOD_$i(CLASS, METHOD, METHOD_NAME, RETURN";
  26. my $argStr;
  27. my @args2;
  28. for (my $j = 1; $j <= $i; $j++) {
  29. print ", ARG$j";
  30. $argStr .= ", ARG$j arg$j";
  31. push @args2, "arg$j";
  32. }
  33. print ") \\\n";
  34. my $argStr2 = join ', ', @args2;
  35. print "RETURN METHOD_NAME(CLASS* c$argStr) { \\\n";
  36. print " return c->METHOD($argStr2); \\\n";
  37. print "}\n";
  38. print "\n";
  39. }
  40. for (my $i = 0; $i < 10; $i++) {
  41. print "#define D_CPP_STATIC_METHOD_$i(CLASS, METHOD, METHOD_NAME, RETURN";
  42. my @args;
  43. my @args2;
  44. for (my $j = 1; $j <= $i; $j++) {
  45. print ", ARG$j";
  46. push @args, "ARG$j arg$j";
  47. push @args2, "arg$j";
  48. }
  49. print ") \\\n";
  50. my $argStr = join ', ', @args;;
  51. my $argStr2 = join ', ', @args2;
  52. print "RETURN METHOD_NAME($argStr) { \\\n";
  53. print " return CLASS::METHOD($argStr2); \\\n";
  54. print "}\n";
  55. print "\n";
  56. }
  57. print "#define D_CPP_BASE_CLASS_OPEN(BASE, BASE_NAME) \\\n";
  58. print "struct BASE_NAME : public BASE { \n";
  59. for (my $i = 0; $i < 10; $i++) {
  60. print "#define D_CPP_VIRTUAL_METHOD_$i(CLASS, METHOD, RETURN";
  61. my @args;
  62. my @args2;
  63. my @args3;
  64. for (my $j = 1; $j <= $i; $j++) {
  65. print ", ARG$j";
  66. push @args, "ARG$j arg$j";
  67. push @args2, ", arg$j";
  68. push @args3, ", ARG$j";
  69. }
  70. print ") \\\n";
  71. my $argStr = join ', ', @args;;
  72. my $argStr2 = join '', @args2;
  73. my $argStr3 = join '', @args3;
  74. print " virtual RETURN METHOD($argStr) { \\\n";
  75. print " return D_##METHOD##_fp(this $argStr2); \\\n";
  76. print " } \\\n";
  77. print " void D_set_##METHOD(RETURN (*fp) (CLASS* $argStr3)) { \\\n";
  78. print " D_##METHOD##_fp = fp; \\\n";
  79. print " } \\\n";
  80. print " RETURN (*D_##METHOD##_fp) (CLASS*$argStr3); \n";
  81. print "\n";
  82. }
  83. for (my $i = 0; $i < 10; $i++) {
  84. print "#define D_CPP_VIRTUAL_METHOD_SETTER_$i(CLASS, METHOD, SETTER_NAME, RETURN";
  85. my @args;
  86. my @args2;
  87. my @args3;
  88. for (my $j = 1; $j <= $i; $j++) {
  89. print ", ARG$j";
  90. push @args, "ARG$j arg$j";
  91. push @args2, ", arg$j";
  92. push @args3, ", ARG$j";
  93. }
  94. print ") \\\n";
  95. my $argStr = join ', ', @args;;
  96. my $argStr2 = join '', @args2;
  97. my $argStr3 = join '', @args3;
  98. print "void SETTER_NAME(CLASS* c, RETURN (*fp) (CLASS*$argStr3)) { \\\n";
  99. print " c->D_set_##METHOD(fp); \\\n";
  100. print "}\n";
  101. print "\n";
  102. }
  103. print "#define D_CPP_BASE_CLASS_CLOSE() \\\n";
  104. print "};\n";
  105. print "\n";
  106. print "#define D_CPP_D_DECLARE(arg) ; \n";
  107. print "\n";