|
82 | 82 |
|
83 | 83 | SELECT_ENUMS_XPATH = 'registry/enums/enum[@name and @value and (not(@api) or not(starts-with(@api, "gles")))]'
|
84 | 84 | SELECT_COMMANDS_XPATH = 'registry/commands/command'
|
85 |
| -SELECT_FEATURES_XPATH = 'registry/*[(self::feature or self::extension) and (not(starts-with(@api,"gles")) and not(starts-with(@supported, "gles")))]/require/*[self::command|self::enum]' |
86 |
| -SELECT_REMOVES_XPATH = 'registry/*[(self::feature or self::extension) and (not(starts-with(@api,"gles")) and not(starts-with(@supported, "gles")))]/remove[@profile="core"]/*[self::command|self::enum]' |
87 | 85 | SELECT_TYPEDEFS_XPATH = 'registry/types/type[(not(@api) or not(starts-with(@api, "gles"))) and (not(@name) or not(starts-with(@name, "khr")))]'
|
88 | 86 | SELECT_TYPE_XPATH = 'ptype/text()|text()'
|
89 | 87 |
|
@@ -147,39 +145,42 @@ def generate_binding_impl(document)
|
147 | 145 | gl_commands = get_commands(document)
|
148 | 146 | gl_enums = get_enums(document)
|
149 | 147 |
|
150 |
| - document.xpath(SELECT_FEATURES_XPATH).each { |
151 |
| - |feature| |
| 148 | + pull_feature = proc { |feature| |
152 | 149 | feature_name = feature['name']
|
153 | 150 | feature_kind = feature.name
|
| 151 | + |
154 | 152 | case feature_kind
|
155 |
| - when 'enum' |
156 |
| - filtered_enums[feature_name] = gl_enums[feature_name] |
| 153 | + when 'enum' then filtered_enums[feature_name] = gl_enums[feature_name] |
| 154 | + when 'command' then filtered_commands[feature_name] = gl_commands[feature_name] |
| 155 | + else raise "Unrecognized feature kind" |
| 156 | + end |
| 157 | + } |
157 | 158 |
|
158 |
| - when 'command' |
159 |
| - filtered_commands[feature_name] = gl_commands[feature_name] |
| 159 | + drop_feature = proc { |feature| |
| 160 | + feature_name = feature['name'] |
| 161 | + feature_kind = feature.name |
160 | 162 |
|
161 |
| - else |
162 |
| - Raise "Unrecognized feature kind" |
| 163 | + case feature_kind |
| 164 | + when 'enum' then filtered_enums.delete(feature_name) |
| 165 | + when 'command' then filtered_commands.delete(feature_name) |
| 166 | + else raise "Unrecognized feature kind" |
163 | 167 | end
|
164 | 168 | }
|
165 | 169 |
|
166 |
| - if GEN_GL3_AND_UP |
167 |
| - document.xpath(SELECT_REMOVES_XPATH).each { |
168 |
| - |feature| |
169 |
| - feature_name = feature['name'] |
170 |
| - feature_kind = feature.name |
171 |
| - case feature_kind |
172 |
| - when 'enum' |
173 |
| - filtered_enums.delete feature_name |
174 |
| - |
175 |
| - when 'command' |
176 |
| - filtered_commands.delete feature_name |
| 170 | + extensions = document.xpath("registry/extensions/extension") |
| 171 | + core_exts = extensions.select { |ext| ext['supported'] =~ /\bglcore\b/ } |
| 172 | + core_exts.each { |ext| |
| 173 | + ext.xpath('extension/require/*[(self::command|self::enum)]').each(&pull_feature) |
| 174 | + } |
177 | 175 |
|
178 |
| - else |
179 |
| - Raise "Unrecognized feature kind" |
180 |
| - end |
181 |
| - } |
182 |
| - end |
| 176 | + features = document.xpath('registry/feature') |
| 177 | + gl_features = features.select { |feature| feature['api'] =~ /\bgl\b/ } |
| 178 | + gl_features.each { |feature| |
| 179 | + feature.xpath('require/*[(self::command|self::enum)]').each(&pull_feature) |
| 180 | + if GEN_GL3_AND_UP |
| 181 | + feature.xpath('remove[@profile="core"]/*[(self::command|self::enum)]').each(&drop_feature) |
| 182 | + end |
| 183 | + } |
183 | 184 | end
|
184 | 185 |
|
185 | 186 | enum_name_length = filtered_enums.map { |k, enum| enum.name.length }.max
|
|
0 commit comments