|
| 1 | +# Constant definition: |
| 2 | +# [ ... |
| 3 | +# "_c", |
| 4 | +# <constant_name as str>, |
| 5 | +# <constant_value as int>, |
| 6 | +# ...] |
| 7 | +_tag_constant = "_c" |
| 8 | + |
| 9 | +# Enum definition: |
| 10 | +# [ ... |
| 11 | +# "_e", |
| 12 | +# <enum_name as str>, |
| 13 | +# <enum_items_count as int>, |
| 14 | +# # First item |
| 15 | +# <enum_item_name as str>, |
| 16 | +# <enum_item_value as int>, |
| 17 | +# # Additional items |
| 18 | +# ... |
| 19 | +# ...] |
| 20 | +_tag_enum = "_e" |
| 21 | + |
| 22 | +# Property definition: |
| 23 | +# [ ... |
| 24 | +# "_p", |
| 25 | +# <property_name as str>, |
| 26 | +# <property_type as str>, |
| 27 | +# <property_getter as str>, |
| 28 | +# <property_setter as str or None>, |
| 29 | +# <property_index as int or None>, |
| 30 | +# ...] |
| 31 | +_tag_property = "_p" |
| 32 | + |
| 33 | +# Signal definition: |
| 34 | +# [ ... |
| 35 | +# "_s", |
| 36 | +# <signal_name as str>, |
| 37 | +# <signal_arguments_count as int>, |
| 38 | +# # First argument |
| 39 | +# <argument_name as str>, |
| 40 | +# <argument_type as str>, |
| 41 | +# <argument_default_value as str or None>, |
| 42 | +# # Additional argument |
| 43 | +# ... |
| 44 | +# ...] |
| 45 | +_tag_signal = "_s" |
| 46 | + |
| 47 | +# Method definition: |
| 48 | +# [ ... |
| 49 | +# "_m", |
| 50 | +# <method_name as str>, |
| 51 | +# <method_hash as int>, |
| 52 | +# <method_flags as int>, |
| 53 | +# <method_return_type as str>, |
| 54 | +# <method_arguments_count as int>, |
| 55 | +# # First argument |
| 56 | +# <argument_name as str>, |
| 57 | +# <argument_type as str>, |
| 58 | +# <argument_default_value as str or None>, |
| 59 | +# # Additional argument |
| 60 | +# ... |
| 61 | +# ...] |
| 62 | +_tag_method = "_m" |
| 63 | +_tag_method_flag_is_const = 1 << 1 |
| 64 | +_tag_method_flag_is_vararg = 1 << 2 |
| 65 | +_tag_method_flag_is_static = 1 << 3 |
| 66 | +_tag_method_flag_is_virtual = 1 << 4 |
| 67 | +_tag_method_flag_is_required = 1 << 5 |
| 68 | +_tag_method_flag_is_property_accessor = 1 << 6 |
| 69 | + |
| 70 | + |
| 71 | +{% for c in api.classes %} |
| 72 | +{{ c.original_name }} = [ |
| 73 | + # Parent |
| 74 | +{% if c.inherits is none %} |
| 75 | + None, |
| 76 | +{% else %} |
| 77 | + "{{ c.inherits.type_name }}", |
| 78 | +{% endif %} |
| 79 | + |
| 80 | + # constants |
| 81 | +{% for constant in c.constants %} |
| 82 | + |
| 83 | + _tag_constant, |
| 84 | + "{{ constant.name }}", |
| 85 | + {{ constant.value }}, |
| 86 | +{% endfor %} |
| 87 | + |
| 88 | + # enums |
| 89 | +{% for enum in c.enums %} |
| 90 | + |
| 91 | + _tag_enum, |
| 92 | + "{{ enum.original_name }}", |
| 93 | + {{ enum.items | length }}, # Items count |
| 94 | +{% for item in enum.items %} |
| 95 | + "{{ item.py_name }}", |
| 96 | + {{ item.value }}, |
| 97 | +{% endfor %} |
| 98 | +{% endfor %} |
| 99 | + |
| 100 | + # properties |
| 101 | +{% for prop in c.properties %} |
| 102 | + |
| 103 | + _tag_property, |
| 104 | + "{{ prop.name }}", |
| 105 | + # type |
| 106 | + "{{ prop.type.type_name }}", |
| 107 | + # getter |
| 108 | + "{{ prop.getter }}", |
| 109 | + # setter |
| 110 | +{% if prop.setter is none %} |
| 111 | + None, |
| 112 | +{% else %} |
| 113 | + "{{ prop.setter }}", |
| 114 | +{% endif %} |
| 115 | + # index |
| 116 | +{% if prop.index is none %} |
| 117 | + None, |
| 118 | +{% else %} |
| 119 | + {{ prop.index }}, |
| 120 | +{% endif %} |
| 121 | +{% endfor %} |
| 122 | + |
| 123 | + # signals |
| 124 | +{% for signal in c.signals %} |
| 125 | + |
| 126 | + _tag_signal, |
| 127 | + "{{ signal.name }}", |
| 128 | + {{ signal.arguments | length }}, # Arguments count |
| 129 | +{% for signal_arg in signal.arguments %} |
| 130 | + "{{ signal_arg.name }}", |
| 131 | + "{{ signal_arg.type.type_name }}", |
| 132 | +{% if signal_arg.default_value is none %} |
| 133 | + None, # No default value |
| 134 | +{% else %} |
| 135 | + {{ signal_arg.default_value.py_value | repr }}, # Default value |
| 136 | +{% endif %} |
| 137 | +{% endfor %} |
| 138 | +{% endfor %} |
| 139 | + |
| 140 | + # methods |
| 141 | +{% for method in c.methods %} |
| 142 | + |
| 143 | + _tag_method, |
| 144 | + "{{ method.name }}", |
| 145 | + {{ method.hash }}, # Hash |
| 146 | + ( |
| 147 | + 0 |
| 148 | +{% if method.is_const %} |
| 149 | + | _tag_method_flag_is_const |
| 150 | +{% endif %} |
| 151 | +{% if method.is_vararg %} |
| 152 | + | _tag_method_flag_is_vararg |
| 153 | +{% endif %} |
| 154 | +{% if method.is_static %} |
| 155 | + | _tag_method_flag_is_static |
| 156 | +{% endif %} |
| 157 | +{% if method.is_virtual %} |
| 158 | + | _tag_method_flag_is_virtual |
| 159 | +{% endif %} |
| 160 | +{% if method.is_required %} |
| 161 | + | _tag_method_flag_is_required |
| 162 | +{% endif %} |
| 163 | +{% if method.is_property_accessor %} |
| 164 | + | _tag_method_flag_is_property_accessor |
| 165 | +{% endif %} |
| 166 | + ), |
| 167 | + "{{ method.return_type.type_name }}", # Return type |
| 168 | + {{ method.arguments | length }}, # Arguments count |
| 169 | +{% for method_arg in method.arguments %} |
| 170 | + "{{ method_arg.name }}", |
| 171 | + "{{ method_arg.type.type_name }}", |
| 172 | +{% if method_arg.default_value is none %} |
| 173 | + None, # No default value |
| 174 | +{% else %} |
| 175 | + {{ method_arg.default_value.py_value | repr }}, # Default value |
| 176 | +{% endif %} |
| 177 | +{% endfor %} |
| 178 | +{% endfor %} |
| 179 | +] |
| 180 | +{% endfor %} |
0 commit comments