bulletGenerate.py 2.2 KB

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