Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Extras / Serialize / HeaderGenerator / bulletGenerate.py
1 import dump
2
3
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
25 dtList = dump.DataTypeList
26
27 out = "autogenerated/"
28 spaces = 4
29
30 def addSpaces(file, space):
31         for i in range(0, space):
32                 file.write(" ")
33
34 def write(file, spaces, string):
35         addSpaces(file, spaces)
36         file.write(string)
37
38 ###################################################################################
39 blender = open(out+"bullet.h", 'w')
40 blender.write(header)
41 blender.write("#ifndef __BULLET_H__\n")
42 blender.write("#define __BULLET_H__\n")
43 #for dt in dtList:
44 #       blender.write("struct %s;\n"%dt.filename)
45
46
47 ###################################################################################
48
49 blender.write("namespace Bullet {\n")
50
51 strUnRes = """
52 // put an empty struct in the case
53 typedef struct bInvalidHandle {
54         int unused;
55 }bInvalidHandle;
56
57 """
58 blender.write(strUnRes)
59
60 for dt in dtList:
61         write(blender, 4, "class %s;\n"%dt.name)
62
63
64 for dt in dtList:
65                 
66         strUpper = dt.filename.upper()
67         
68         blender.write("// -------------------------------------------------- //\n")
69
70         write(blender, 4, "class %s\n"%dt.name)
71
72         write(blender, 4, "{\n")
73         write(blender, 4, "public:\n")
74         for i in dt.dataTypes:
75                 write(blender, 8, i+";\n")
76
77         write(blender, 4, "};\n")
78         
79         blender.write("\n\n")
80         
81 blender.write("}\n")
82 blender.write("#endif//__BULLET_H__")
83 blender.close()