• Home
  • Raw
  • Download

Lines Matching +full:to +full:- +full:regex +full:- +full:range

1 #!/usr/bin/python3 -i
3 # Copyright 2013-2024 The Khronos Group Inc.
5 # SPDX-License-Identifier: Apache-2.0
36 s - string to convert"""
57 - Core API features (those defined with a `<feature>` tag)
58 - (sort VKSC after VK - this is Vulkan-specific)
59 - ARB/KHR/OES (Khronos extensions)
60 - other (EXT/vendor extensions)"""
75 """Sort key for regSortFeatures - key is the sortorder attribute."""
81 """Sort key for regSortFeatures - key is the extension name."""
87 """Sort key for regSortFeatures - key is the feature version.
94 """Sort key for regSortFeatures - key is the extension number.
103 - Sorts by explicit sort order (default 0) relative to other features
104 - then by feature category ('feature' or 'extension'),
105 - then by version number (for features)
106 - then by extension number (for extensions)"""
114 …"""Error raised when a Generator tries to do something that requires GeneratorOptions but it is No…
124 …"""Error raised when a Generator tries to do something that requires a Registry object but it is N…
134 …"""Error raised when a Generator tries to do something that requires a Conventions object but it i…
174 - conventions - may be mandatory for some generators:
176 - filename - basename of file to generate, or None to write to stdout.
177 - directory - directory in which to generate filename
178 - genpath - path to previously generated files, such as apimap.py
179 - apiname - string matching `<api>` 'apiname' attribute, e.g. 'gl'.
180 - mergeApiNames - If not None, a comma separated list of API names
181 to merge into the API specified by 'apiname'
182 - profile - string specifying API profile , e.g. 'core', or None.
183 - versions - regex matching API versions to process interfaces for.
184 Normally `'.*'` or `'[0-9][.][0-9]'` to match all defined versions.
185 - emitversions - regex matching API versions to actually emit
187 when deciding which interfaces to generate). For GL 4.3 glext.h,
188 this might be `'1[.][2-5]|[2-4][.][0-9]'`.
189 - defaultExtensions - If not None, a string which must in its
191 the `<extension>`. Defaults to None. Usually the same as apiname.
192 - addExtensions - regex matching names of additional extensions
193 to include. Defaults to None.
194 - removeExtensions - regex matching names of extensions to
196 to None.
197 - emitExtensions - regex matching names of extensions to actually emit
199 deciding which interfaces to generate). Defaults to None.
200 - emitSpirv - regex matching names of extensions and capabilities
201 to actually emit interfaces for.
202 - emitFormats - regex matching names of formats to actually emit
204 - reparentEnums - move <enum> elements which extend an enumerated
205 type from <feature> or <extension> elements to the target <enums>
208 or <extension> being complete. Defaults to True.
209 - sortProcedure - takes a list of FeatureInfo objects and sorts
210 them in place to a preferred order in the generated output.
211 - requireCommandAliases - if True, treat command aliases
213 - requireDepends - whether to follow API dependencies when emitting
217 - core API versions
218 - Khronos (ARB/KHR/OES) extensions
219 - All other extensions
220 - By core API version number or extension number in each group.
222 The regex patterns can be None or empty, in which case they match
229 "basename of file to generate, or None to write to stdout."
232 """path to previously generated files, such as apimap.py"""
235 "directory in which to generate filename"
241 "comma separated list of API names to merge into the API specified by 'apiname'"
247 """regex matching API versions to process interfaces for.
248 Normally `'.*'` or `'[0-9][.][0-9]'` to match all defined versions."""
251 """regex matching API versions to actually emit
253 when deciding which interfaces to generate). For GL 4.3 glext.h,
254 this might be `'1[.][2-5]|[2-4][.][0-9]'`."""
259 the `<extension>`. Defaults to None. Usually the same as apiname."""
262 """regex matching names of additional extensions
263 to include. Defaults to None."""
266 """regex matching names of extensions to
268 to None."""
271 """regex matching names of extensions to actually emit
273 deciding which interfaces to generate)."""
276 """regex matching names of extensions and capabilities
277 to actually emit interfaces for."""
280 """regex matching names of formats
281 to actually emit interfaces for."""
284 """boolean specifying whether to remove <enum> elements from
289 them in place to a preferred order in the generated output.
323 # categoryToPath - map XML 'category' to include file directory name
336 # List of string names to break on
347 - errFile, warnFile, diagFile - file handles to write errors,
348 warnings, diagnostics to. May be None to not write."""
379 """Write a message of different categories to different
382 - `level`
383 - 'diag' (diagnostic, voluminous)
384 - 'warn' (warning)
385 - 'error' (fatal error - raises exception after logging)
387 - `*args` - print()-style arguments to direct to corresponding log"""
408 - elem - <enum> Element
409 - needsNum - generate a numeric representation of the element value
410 - bitwidth - size of the numeric representation in bits (32 or 64)
411 - forceSuffix - if True, always use a 'U' / 'ULL' suffix on integers
412 - parent_for_alias_dereference - if not None, an Element containing
413 the parent of elem, used to look for elements this is an alias of
417 - first element - integer representation of the value, or None
420 - second element - string representation of the value
424 - A 'value' attribute simply contains the value.
425 - A 'bitpos' attribute defines a value by specifying the bit
427 - An 'offset','extbase','extends' triplet specifies a value
428 as an offset to a base value defined by the specified
429 'extbase' extension name, which is then cast to the
433 - An 'alias' attribute contains the name of another enum
445 # print('About to translate value =', value, 'type =', type(value))
448 # If there is a non-integer, numeric 'type' attribute (e.g. 'u' or
449 # 'ull'), append it to the string value.
458 self.logMsg('diag', 'Enum', name, '-> value [', numVal, ',', value, ']')
469 self.logMsg('diag', 'Enum', name, '-> bitpos [', numVal, ',', value, ']')
484 numVal = self.extBase + (extnumber - 1) * self.extBlockSize + offset
486 numVal *= -1
489 self.logMsg('diag', 'Enum', name, '-> offset [', numVal, ',', value, ']')
506 - enums - list of `<enum>` Elements
537 # Do not add the duplicate to the returned list
541 # still add this enum to the list.
548 # Track this enum to detect followon duplicates
553 # Add this enum to the list
587 …or bitwidth attribute (', groupElem.get('bitwidth'), ') for ', groupName, ' - must be an integer v…
594 # or as 32-bit C enums. 64-bit types must use uint64_t values.
604 …oupElem.get('bitwidth'), ') for bitmask type ', groupName, ' - must be less than or equal to 64\n')
611 … groupElem.get('bitwidth'), ') for enum type ', groupName, ' - must be less than or equal to 32\n')
630 # Maximum allowable value for a flag (unsigned 64-bit integer)
631 maxValidValue = 2**(64) - 1
641 # Accumulate non-numeric enumerant values separately and append
642 # them following the numeric values, to allow for aliases.
649 # Convert the value to an integer and use that to track min/max.
650 # Values of form -(number) are accepted but nothing more complex.
655 # Range check for the enum value
657 …self.logMsg('error', 'Allowable range for flag types in C is [', minValidValue, ',', maxValidValue…
673 … # So initializing an alias from another 'static const' value would fail to compile.
674 # Work around this by chasing the aliases to get the actual value.
691 # Now append the non-numeric enumerant values
702 # Break the group name into prefix and suffix portions for range
704 expandName = re.sub(r'([0-9]+|[a-z_])([A-Z0-9])', r'\1_\2', groupName).upper()
707 expandSuffixMatch = re.search(r'[A-Z][A-Z]+$', groupName)
719 # Allowable range for a C enum - which is that of a signed 32-bit integer
720 maxValidValue = 2**(32 - 1) - 1
721 minValidValue = (maxValidValue * -1) - 1
736 # Accumulate non-numeric enumerant values separately and append
737 # them following the numeric values, to allow for aliases.
746 # Convert the value to an integer and use that to track min/max.
747 # Values of form -(number) are accepted but nothing more complex.
775 # Range check for the enum value
777 …self.logMsg('error', 'Allowable range for C enum types is [', minValidValue, ',', maxValidValue, '…
780 # Do not track min/max for non-numbers (numVal is None)
792 # Now append the non-numeric enumerant values
795 # Generate min/max value tokens - legacy use case.
799 … f' {expandPrefix}_RANGE_SIZE{expandSuffix} = ({maxName} - {minName} + 1),'))
801 # Generate a range-padding value to ensure the enum is 32 bits, but
823 usually just integers or floating-point numbers."""
874 - genOpts - GeneratorOptions controlling what is generated and how"""
885 # Try to import the API dictionary, apimap.py, if it exists. Nothing
900 … self.outFile = tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', newline='\n', delete=False)
919 # On successfully generating output, move the temporary file to the
933 - interface - element for the `<version>` / `<extension>` to generate
934 - emit - actually write to the header only when True"""
950 the shared enumerant-generating interfaces (buildEnumCDecl, etc.).
954 - name - name of the API
955 - mustBeFound - If True, when requirements for 'name' cannot be
964 raise UserWarning('Attempt to generate', featureType,
970 - typeinfo - TypeInfo for a type
972 Extend to generate as desired in your derived class."""
978 - typeinfo - TypeInfo for a type interpreted as a struct
980 Extend to generate as desired in your derived class."""
983 # The mixed-mode <member> tags may contain no-op <comment> tags.
984 # It is convenient to remove them here where all output generators
993 - groupinfo - GroupInfo for a group.
995 Extend to generate as desired in your derived class."""
1002 - enuminfo - EnumInfo for an enum
1003 - name - enum name
1005 Extend to generate as desired in your derived class."""
1011 - cmdinfo - CmdInfo for a command
1013 Extend to generate as desired in your derived class."""
1019 - spirvinfo - SpirvInfo for a command
1021 Extend to generate as desired in your derived class."""
1027 - formatinfo - FormatInfo
1029 Extend to generate as desired in your derived class."""
1035 - stageinfo - SyncStageInfo
1037 Extend to generate as desired in your derived class."""
1043 - accessinfo - AccessInfo
1045 Extend to generate as desired in your derived class."""
1051 - pipelineinfo - SyncPipelineInfo
1053 Extend to generate as desired in your derived class."""
1057 """Turn a `<proto>` `<name>` into C-language prototype
1060 - name - contents of `<name>` tag
1061 - tail - whatever text follows that tag in the Element"""
1067 """Make the function-pointer typedef name for a command."""
1077 - param - Element (`<param>` or `<member>`) to format
1078 - aligncol - if non-zero, attempt to align the nested `<name>` element
1093 # OpenXR-specific macro insertion - but not in apiinc for the spec
1096 … self.logMsg('diag', 'Aligning parameter', elem.text, 'to column', self.genOpts.alignFuncParam)
1100 # This works around a problem where very long type names -
1101 # longer than the alignment column - would run into the tail
1103 paramdecl = paramdecl.ljust(aligncol - 1) + ' '
1105 … self.logMsg('diag', 'Adjust length of parameter decl from', oldLen, 'to', newLen, ':', paramdecl)
1107 if (self.misracppstyle() and prefix.find('const ') != -1):
1108 # Change pointer type order from e.g. "const void *" to "void const *".
1109 # If the string starts with 'const', reorder it to be after the first type.
1129 - param - Element (`<param>` or `<member>`) to identify"""
1143 # OpenXR-specific macro insertion
1156 - info - TypeInfo or CommandInfo.
1203 …"""Try to do check if a structure is always considered valid (i.e. there is no rules to its accept…
1206 …raise RuntimeError("To use isStructAlwaysValid, be sure your options include a Conventions object.…
1219 … self.logMsg('error', f'isStructAlwaysValid({structname}) - structure not found in typedict')
1252 """Check if the parameter passed in is a pointer to an array.
1270 - elem - `<enum>` element to test"""
1273 '->', required)
1298 `<command>` Element, as a two-element list of strings.
1300 - cmd - Element containing a `<command>` tag"""
1332 # Squeeze out multiple spaces - there is no indentation
1352 # Non-indented parameters
1365 # Change pointer type order from e.g. "const void *" to "void const *".
1366 … # If the string starts with 'const', reorder it to be after the first type.
1367 if (prefix.find('const ') != -1):
1384 """Print a newline to the output file (utility function)"""