class

Bindgen::Processor::SanityCheck

Inherits Bindgen::Processor::Base < Bindgen::Graph::Visitor < Reference < Object

Does sanity-checks on the graph. If any check fails, a message written to STDERR and the process is exited.

Checks are as follows:

  • Name of enums, libs, structures, classes, modules and aliases are valid
  • Name of methods are valid
  • Enumerations have at least one constant
  • Enumeration constants are correctly named
  • Flag-enumerations don't have All nor None constants
  • Crystal method overloads are unambiguous
  • Method arguments and result types are reachable
  • Variadic methods are directly bound
  • Alias targets are reachable
  • Class base-classes are reachable
  • Structure fields are of a supported and reachable type

Constants

ARRAY_BINDING_TYPES = {"Binding::CrystalSlice", "Binding::CrystalArray"}

Binding types of C arrays, defined in glue.cr.

ARRAY_RX = /^(?:Slice|BindgenHelper::ArrayView)\((.+)\)$/

Regular expression for the Crystal type of a C array of other than built-in types, capturing the element type: Slice(Color)

CAMEL_CASE_RX = /^[A-Z_][A-Za-z0-9_]*$/

Regular expression for a camel-cased symbol

CONSTANT_RX = /^[A-Z_][A-Z0-9_]*$/

Regular expression for a CONSTANT

ENUM_FLAG_ALL = "All"

The all-flags constant in a flag-enum

ENUM_FLAG_NONE = "None"

The no-flags constant in a flag-enum

ENUMERABLE_RX = /^(?:Enumerable|Tuple)(?:\([A-Za-z0-9_():*{}, ]*\))?$/

Regular expression for a Crystal Enumerable typename, which may be of tuples: Enumerable({K, V}) TODO: support other Crystal stdlib types (which might not correspond to any C++ type at all)

Log = ::Log.for(self)

Does sanity-checks on the graph. If any check fails, a message written to STDERR and the process is exited.

Checks are as follows:

  • Name of enums, libs, structures, classes, modules and aliases are valid
  • Name of methods are valid
  • Enumerations have at least one constant
  • Enumeration constants are correctly named
  • Flag-enumerations don't have All nor None constants
  • Crystal method overloads are unambiguous
  • Method arguments and result types are reachable
  • Variadic methods are directly bound
  • Alias targets are reachable
  • Class base-classes are reachable
  • Structure fields are of a supported and reachable type
METHOD_NAME_RX = /^[a-z_][A-Za-z0-9_]*[?!=]?$/

Regular expression describing a method name

OPERATOR_METHOD_NAME_RX = /^([\+\-\*\/\%\&\|\^\>\<\~]|\<\<|\>\>|[\!\=\<\>]=|=[\<\>]|\[\])$/

Regular expression describing a operator method name

TYPE_DECL_RX = /^[A-Z_][A-Za-z0-9_]*(?:\(\*?[A-Z_][A-Za-z0-9_]*(?:, \*?[A-Z_][A-Za-z0-9_]*)*\))?$/

Regular expression for a type declaration, possibly generic

Constructors

new(*_args)
Source

Instance methods

process(*_args)
Source
visit_class(klass)

Check for ambiguous Crystal overloads

Source
visit_enum(enumeration)

Check enumeration constants

Source
visit_library(library)

Temporarily switch the platform.

Source
visit_node(node)

Check for correct naming of nodes.

Source
visit_platform_specific(specific)

Only visit non-C++ specifics

Source
visit_struct(structure)

Check for invalid types in structures

Source
visit_union(structure)

Check for invalid types in unions

Source

Nested types