OpenGLBindingGenerator::Crystalize
Provides methods for converting a C-style identifier to a Crystalize-like one.
Two cases are provided: #pascal_case and #underscore_case.
A #crystalize method is exposed that returns the desired casing for the type.
Constants
ACRONYMS = (["ClampD", "ClampF", "IntPtr", "SSize", "STime", "UTime", "UInt", "UIntPtr", "UShort", "UByte", "USize", "SNorm", "SizeI", "SizeIPtr", "GreaterEqual", "NotEqual", "LessEqual", "PName", "DebugProc", "GLSL", "BGRA", "RGBA", "SRGB", "SGIX", "SGIS", "SPIR", "QCOM", "3DFX", "RGTC", "BPTC", "BGR", "RGB", "ARB", "AMD", "IBM", "ARM", "NEC", "KPC", "PGI", "SGI", "OES", "OEM", "ATI", "EXT", "ETC", "EAC", "IMG", "LOD", "API", "LSB", "MSB", "CCW", "CW", "NV", "RG", "FJ", "HP", "MS", "UI"] of ::String).map do |acronym|
regex = /(\A|[\d_])#{acronym.downcase}(\Z|[\d_])/
{acronym, regex}
end
COMMAND_SUFFIXES = (Indexable.cartesian_product([[""] + (["1", "2", "3", "4", "4n", "64"] of ::String), [""] + (["b", "s", "i", "i64", "f", "d", "ub", "us", "ui", "ui64", "fi", "x"] of ::String), [""] + (["_v", "v"] of ::String)])).map(&.join).sort! do |a, b| b.size <=> a.size end.tap(&.pop)
All possible combinations of command suffixes.
FIXES = [{"shadersource", "shader_source"}, {"i6__4v", "_i64_v"}, {"gldebugproc", "DebugProc"}, {"doublebuffer", "DoubleBuffer"}, {"buffersub", "buffer_sub"}, {"gequal", "GreaterEqual"}, {"lequal", "LessEqual"}, {"CCW", "CounterClockwise"}, {"CClockwise", "CounterClockwise"}, {"CW", "Clockwise"}]
SUFFIX_FIXES = ["attri_b", "shader_s", "stat_us", "indice_s", "indexe_d", "enable_d", "inde_x", "fixe_d", "minma_x", "buffer_s"] of ::String
Unintended changes to command suffixes.
TRIM_PREFIXES = ["gl_"] of ::String
TRIM_SUFFIXES = ["_bit"] of ::String
VARIANT_COMMANDS = Set.new(["glBlendEquation", "glBlendFunc", "glClearBuffer", "glClearDepth", "glClearNamedFramebuffer", "glColorMask", "glDepthRangeArray", "glFramebuffer", "glDepthRangef", "glDisable", "glEnable", "glIsEnabled", "glGet", "glNamedFramebufferParameter", "glPixelStore", "glPointParameter", "glProgramParameter", "glProgramUniform", "glSampleMask", "glSamplerParameter", "glScissorIndexed", "glTexParameter", "glTextureParameter", "glUniform", "glUniformMatrix", "glUniformSubroutines", "glVertexAttrib", "glViewportArray", "glViewportIndexed", "glPatchParameter", "glCreateShaderProgram", "glIndex", "glColor", "glEdgeFlag", "glEvalCoord", "glFog", "glIndex", "glLight", "glLoadMatrix", "glLoadTransposeMatrix", "glLoadTransposeMatrix", "glMap", "glMaterial", "glTranslate", "glScale", "glMultiTexCoord", "glMultMatrix", "glMultTransposeMatrix", "glNormal", "glPixelMap", "glPixelTransfer", "glPointParameter", "glRasterPos", "glRect", "glRotate", "glSecondaryColor", "glScissor", "glTexCoord", "glTexEnv", "glTexGen", "glVertex", "glWindowPos"] of ::String)
Commands that can have suffixes.
Instance methods
crystalize(namespace = nil)
Name as it would appear in Crystal. By default, this produces a PascalCase string. Override to select a different casing.