bulletGenerate.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import sys
  2. sys.path.append(".")
  3. import dump
  4. header = """/* Copyright (C) 2011 Erwin Coumans & Charlie C
  5. *
  6. * This software is provided 'as-is', without any express or implied
  7. * warranty. In no event will the authors be held liable for any damages
  8. * arising from the use of this software.
  9. *
  10. * Permission is granted to anyone to use this software for any purpose,
  11. * including commercial applications, and to alter it and redistribute it
  12. * freely, subject to the following restrictions:
  13. *
  14. * 1. The origin of this software must not be misrepresented; you must not
  15. * claim that you wrote the original software. If you use this software
  16. * in a product, an acknowledgment in the product documentation would be
  17. * appreciated but is not required.
  18. * 2. Altered source versions must be plainly marked as such, and must not be
  19. * misrepresented as being the original software.
  20. * 3. This notice may not be removed or altered from any source distribution.
  21. */
  22. // Auto generated from Bullet/Extras/HeaderGenerator/bulletGenerate.py
  23. """
  24. dtList = dump.DataTypeList
  25. out = "autogenerated/"
  26. spaces = 4
  27. def addSpaces(file, space):
  28. for i in range(0, space):
  29. file.write(" ")
  30. def write(file, spaces, string):
  31. addSpaces(file, spaces)
  32. file.write(string)
  33. ###################################################################################
  34. blender = open(out+"bullet.h", 'w')
  35. blender.write(header)
  36. blender.write("#ifndef __BULLET_H__\n")
  37. blender.write("#define __BULLET_H__\n")
  38. #for dt in dtList:
  39. # blender.write("struct %s;\n"%dt.filename)
  40. ###################################################################################
  41. blender.write("namespace Bullet {\n")
  42. strUnRes = """
  43. // put an empty struct in the case
  44. typedef struct bInvalidHandle {
  45. int unused;
  46. }bInvalidHandle;
  47. """
  48. blender.write(strUnRes)
  49. for dt in dtList:
  50. write(blender, 4, "class %s;\n"%dt.name)
  51. for dt in dtList:
  52. strUpper = dt.filename.upper()
  53. blender.write("// -------------------------------------------------- //\n")
  54. write(blender, 4, "class %s\n"%dt.name)
  55. write(blender, 4, "{\n")
  56. write(blender, 4, "public:\n")
  57. for i in dt.dataTypes:
  58. write(blender, 8, i+";\n")
  59. write(blender, 4, "};\n")
  60. blender.write("\n\n")
  61. blender.write("}\n")
  62. blender.write("#endif//__BULLET_H__")
  63. blender.close()