module Bindgen::Util
Defined in:
bindgen/util.crbindgen/util/create_by_name.cr
bindgen/util/find_matching.cr
bindgen/util/prefix.cr
bindgen/util/tribool.cr
Constant Summary
-
BACKREFERENCE_RX =
/\\(\d)/
-
Matches back-references in strings.
-
BALANCED_PARENS_RX =
/\( ( [^()]++ | (?R) )* \)/x
-
Matches strings with balanced parentheses. (http://www.pcre.org/original/doc/html/pcrepattern.html#SEC23)
-
FAIL_RX =
/(?!)/
-
Matches absolutely nothing, not even the empty string.
Class Method Summary
-
.format_bytes(bytes : Int, explicit_sign = false) : String
Formats the bytes amount as nice string.
-
.mangle_type_name(full_type_name : String)
Mangles the type name of full_type_name for the binding function: * A pointer-star is turned into
X
* A reference-ampersand is turned intoR
* Any non-word character is replaced with_
-
.mangle_type_names(full_type_names : String)
Mangles a list of type-names into a combined string.
-
.pattern_rewrite(pattern : String | Nil, groups) : String
Using the rewrite pattern, containing back-references, builds a new string.
-
.replace_backreferences(string : String, captures) : String
Replaces back-references in strings with captures from an existing
Array(String)
orRegex::MatchData
. -
.template(haystack : String, replacement : String | Nil = nil, env = ENV) : String
Templates the string haystack, replacing occurences of
%
with replacement. -
.uniq_by(list : Array, &)
Mimics Rubys
Enumerable#uniq_by
.
Class Method Detail
Formats the bytes amount as nice string.
Mangles the type name of full_type_name for the binding function:
- A pointer-star is turned into
X
- A reference-ampersand is turned into
R
- Any non-word character is replaced with
_
Mangles a list of type-names into a combined string.
Using the rewrite pattern, containing back-references, builds a new
string. If pattern is nil
, then groups[1]
, then groups[0]
is
returned (Whichever is non-nil first).
Replaces back-references in strings with captures from an existing
Array(String)
or Regex::MatchData
.
Templates the string haystack, replacing occurences of %
with
replacement. If replacement is nil
, this behaviour is disabled.
The user can also access environment variables using the syntax {NAME}
,
with NAME
being the variable name. A default fallback, in case the
NAME
is unset, can be provided through a pipe symbol: {NAME|default}
.
It's possible to fall back to the character expansion: {NAME|%}
Mimics Rubys Enumerable#uniq_by
. Takes a list, and makes all values
in it unique by yielding all pairs, keeping only those items where the
block returned a falsy value.
This method is O(n²)
, prefer Enumerable#uniq
if possible.