1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 # Used for generating API diff's between releases
22 # ./blender.bin --background --python release/test/rna_info_dump.py
27 def api_dump(use_properties=True, use_functions=True):
30 if prop.type == "pointer":
31 return prop.fixed_type.identifier
35 def func_to_str(struct_id_str, func_id, func):
38 for prop in func.args:
39 data_str = "%s %s" % (prop_type(prop), prop.identifier)
41 data_str += "[%d]" % prop.array_length
42 if not prop.is_required:
43 data_str += "=%s" % prop.default_str
46 data_str = "%s.%s(%s)" % (struct_id_str, func_id, ", ".join(args))
47 if func.return_values:
48 return_args = ", ".join(prop_type(arg) for arg in func.return_values)
49 if len(func.return_values) > 1:
50 data_str += " --> (%s)" % return_args
52 data_str += " --> %s" % return_args
55 def prop_to_str(struct_id_str, prop_id, prop):
57 prop_str = " <-- %s" % prop_type(prop)
59 prop_str += "[%d]" % prop.array_length
61 data_str = "%s.%s %s" % (struct_id_str, prop_id, prop_str)
64 def struct_full_id(v):
65 struct_id_str = v.identifier # "".join(sid for sid in struct_id if struct_id)
67 for base in v.get_bases():
68 struct_id_str = base.identifier + "|" + struct_id_str
74 for struct_id, v in sorted(struct.items()):
75 struct_id_str = struct_full_id(v)
77 funcs = [(func.identifier, func) for func in v.functions]
79 for func_id, func in funcs:
80 data.append(func_to_str(struct_id_str, func_id, func))
82 for prop in v.properties:
83 if prop.collection_type:
84 funcs = [(prop.identifier + "." + func.identifier, func) for func in prop.collection_type.functions]
85 for func_id, func in funcs:
86 data.append(func_to_str(struct_id_str, func_id, func))
88 data.append("# * functions *")
93 for struct_id, v in sorted(struct.items()):
94 struct_id_str = struct_full_id(v)
96 props = [(prop.identifier, prop) for prop in v.properties]
98 for prop_id, prop in props:
99 data.append(prop_to_str(struct_id_str, prop_id, prop))
101 for prop in v.properties:
102 if prop.collection_type:
103 props = [(prop.identifier + "." + prop_sub.identifier, prop_sub) for prop_sub in prop.collection_type.properties]
104 for prop_sub_id, prop_sub in props:
105 data.append(prop_to_str(struct_id_str, prop_sub_id, prop_sub))
107 data.insert(0, "# * properties *")
111 struct = rna_info.BuildRNAInfo()[0]
115 data.extend(dump_funcs())
118 data.extend(dump_props())
120 if bpy.app.background:
122 sys.stderr.write("\n".join(data))
123 sys.stderr.write("\n\nEOF\n")
125 text = bpy.data.texts.new(name="api.py")
126 text.from_string(data)
130 if __name__ == "__main__":