Name
SPVM::Fn - SPVM Starndard Functions
Description
The Fn class of SPVM has methods for numbers, strings, general utilities.
Usage
use Fn;
# Cut a newline LF
my $line = (mutable string)copy "abc\n";
Fn->chomp($line);
# Contains
my $found = Fn->contains("pppabcde", "bcd");
# Split
my $csv = "foo,bar,baz";
my $args_width = Fn->split(",", $string);
# Join
my $args_width = ["foo", "bar", "baz"];
my $csv = Fn->join(",", $args_width);
# Constant values
my $byte_max = Fn->BYTE_MAX();
my $short_max = Fn->SHORT_MAX();
my $int_max = Fn->INT_MAX();
my $long_max = Fn->LONG_MAX();
Enumerations
GET_CODE_POINT_ERROR_OVER_STRING_RANGE
Returns -1. The return type is the int
type.
GET_CODE_POINT_ERROR_INVALID_UTF8
Returns -2. The return type is the int
type.
Class Methods
BYTE_MAX
static method BYTE_MAX : int ();
The same as "INT8_MAX".
BYTE_MIN
static method BYTE_MIN : int ();
The same as "INT8_MIN".
DBL_MAX
static method DBL_MAX : double ();
Returns the value of DBL_MAX
macro defined in float.h
header of the C language.
DBL_MIN
static method DBL_MIN : double ();
Returns the value of DBL_MIN
macro defined in float.h
header of the C language.
DOUBLE_MAX
static method DOUBLE_MAX : double ();
The same as "DBL_MAX".
DOUBLE_MIN
static method DOUBLE_MIN : double ();
The same as "DBL_MIN".
FLOAT_MAX
static method FLOAT_MAX : float ();
The same as "FLT_MAX".
FLOAT_MIN
static method FLOAT_MIN : float();
The same as "FLT_MIN".
FLT_MAX
static method FLT_MAX : float ();
Returns the value of FLT_MAX
macro defined in float.h
header of the C language.
FLT_MIN
static method FLT_MIN : float ();
Returns the value of FLT_MIN
macro defined in float.h
header of the C language.
INT16_MAX
static method INT16_MAX : int ();
Returns 32767. The maximum value of the signed 16bit integer.
INT16_MIN
static method INT16_MIN : int ();
Returns -32768. The minimal value of the signed 16bit integer.
INT32_MAX
static method INT32_MAX : int ();
Returns 2147483647. The maximum value of the signed 32bit integer.
INT32_MIN
static method INT32_MIN : int ();
Returns -2147483648. The minimal value of the signed 32bit integer.
INT64_MAX
static method INT64_MAX : long ();
Returns 9223372036854775807. The maximum value of the signed 64bit integer.
INT64_MIN
static method INT64_MIN : long ();
Returns -9223372036854775808. The minimal value of the signed 64bit integer.
INT8_MAX
static method INT8_MAX : int ();
Returns 127. The maximum value of the signed 8bit integer.
INT8_MIN
static method INT8_MIN : int ();
Returns -128. The minimal value of the signed 8bit integer.
INT_MAX
static method INT_MAX : int ();
The same as "INT32_MAX".
INT_MIN
static method INT_MIN : int ();
The same as "INT32_MIN".
LONG_MAX
static method LONG_MAX : long ();
The same as "INT64_MAX".
LONG_MIN
static method LONG_MIN : long ();
The same as "INT64_MIN".
RAND_MAX
static method RAND_MAX : int ();
Returns 2147483647.
SHORT_MAX
static method SHORT_MAX : int ();
The same as "INT16_MAX".
SHORT_MIN
static method SHORT_MIN : int ();
The same as "INT16_MIN".
UBYTE_MAX
static method UBYTE_MAX : int ();
The same as "UINT8_MAX".
UINT16_MAX
static method UINT16_MAX : int ();
Returns -1. This represents 0xFFFF
in the unsigned 16bit integer in 2's complement.
UINT32_MAX
static method UINT32_MAX : int ();
Returns -1. This represents 0xFFFFFFFF
in the unsigned 32bit integer in 2's complement.
UINT64_MAX
static method UINT64_MAX : long ();
Returns -1. This represents 0xFFFFFFFFFFFFFFFF
in the unsigned 64bit integer in 2's complement.
UINT8_MAX
static method UINT8_MAX : int ();
Returns -1. This represents 0xFF
in the unsigned 8bit integer in 2's complement.
UINT_MAX
static method UINT_MAX : int ();
The same as "UINT32_MAX".
ULONG_MAX
static method ULONG_MAX : long
The same as "UINT64_MAX".
USHORT_MAX
static method USHORT_MAX : int ();
The same as "UINT16_MAX".
abs
static method abs : int ($value : int);
Returns the absolute value of $value.
chomp
static method chomp : void ($string : mutable string);
Removes \r\n
or \n
at the end of $string.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
chompr
static method chompr : string ($string : string);
Copies $string and removes \r\n
or \n
at the end of the copied string and returns it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
chr
static method chr : string ($code_point : int);
Converts $code_point to the UTF-8 character and return it.
If $code_point is not a Unicode scalar value, return undef.
contains
static method contains : int ($string : string, $substring : string, $string_offset : int = 0, $string_length : int = -1);
The alias for the following code using ""index".
my $ret = Fn->index($string, $substring, $string_offset, $string_length) >= 0;
copy_string
static method copy_string : string ($string : string);
The alias for the following code using the copy operator
my $ret = copy $string;
crand
static method crand : int ($seed : int*);
Create a random number from 0 to "RAND_MAX" using $seed and return it.
$seed is updated.
This method is thread safe.
Examples:
use Sys::Time;
my $seed = (int)Sys::Time->time;
my $crand0 = Fn->crand(\$seed);
my $crand1 = Fn->crand(\$seed);
equals_string_range
static method equals_string_range : int ($string1 : string, $string1_offset : int, $string2 : string, $string2_offset : int, $length : int);
Compares $string1 + $string1_offset with $string2 + $string2_offset by $length. If they are euqal, returns 1, otherwise returns 0.
If $length is 0, returns 1.
Exceptions:
$string1 must be defined. Otherwise an exception is thrown.
$string2 must be defined. Otherwise an exception is thrown.
$string1_offset must be greater than or equal to 0. Otherwise an exception is thrown.
$string2_offset must be greater than or equal to 0. Otherwise an exception is thrown.
get_code_point
static method get_code_point : int ($string : string, $offset_ref : int*);
Parses the UTF-8 character at the value reffered by $offset_ref of $string and return its Unicode code point.
The offset is updated to the position of the next UTF-8 character.
If the offset is greater than the length of the string, return the value of "GET_CODE_POINT_ERROR_OVER_STRING_RANGE".
If the UTF-8 character is invalid, return the value of "GET_CODE_POINT_ERROR_INVALID_UTF8".
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$offset must be greater than or equal to 0. Otherwise an exception is thrown.
hex
static method hex : int ($hex_string : string);
Converts $hex_string to the int
value and return it.
Exceptions:
$hex string must be defined. Otherwise an exception is thrown.
The length of $hex string must be 1 to 8. Otherwise an exception is thrown.
$hex string must contain only hex characters 0-9a-zA-Z
. Otherwise an exception is thrown.
index
static method index : int ($string : string, $substring : string, $begin : int = 0, $end : int = -1);
Searches for $substring in the range of $string from $begin to $end.
The search is performed from the beginning of the range of $string.
If $substring is found, returns the found offset, otherwise returns -1.
If $end is less than 0, $end is set to the length of $string minus 1.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$substring must be defined. Otherwise an exception is thrown.
$begin must be greater than or equal to 0. Otherwise an exception is thrown.
$end must be less than the length of $string.
init_string
static method init_string : void ($string : mutable string, $ascii_code : int = 0, $offset = 0 int, $length = -1);
Sets the characters in $string from $offset to the position proceeded by $length to $ascii_code.
If $length is less than 0, $length is set to the length of $string - $offset.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$offset + $length must be less than or equal to the length of $string.
is_alnum
static method is_alnum : int ($code_point : int);
If the Unicode $code_point is an ASCII alphanumeric A-Za-z0-9
, return 1. Otherwise return 0.
is_alpha
static method is_alpha : int ($code_point : int);
If the Unicode $code_point is an ASCII alphabetic A-Za-z
, return 1. Otherwise return 0.
is_array
static method is_array : int ($object : object);
If $object is defined and the type of $object is the array type, return 1. Otherwise return 0.
"is_array" in SPVM::Document::NativeAPI is used to check the type.
is_blank
static method is_blank : int ($code_point : int);
If the Unicode $code_point is an ASCII blank 0x20(SP, ' ')
, 0x09(HT, '\t')
, return 1. Otherwise return 0.
is_class
static method is_class : int ($object : object);
If $object is defined and the type of $object is the class type, return 1. Otherwise return 0.
"is_class" in SPVM::Document::NativeAPI is used to check the type.
is_cntrl
static method is_cntrl : int ($code_point : int);
If the Unicode $code_point is an ASCII control character 0x00-0x1F
, 0x7F
, return 1. Otherwise return 0.
is_digit
static method is_digit : int ($code_point : int);
If the Unicode $code_point is an ASCII decimal digit 0-9, return 1. Otherwise return 0.
is_graph
static method is_graph : int ($code_point : int);
If $character is an ASCII graphical character 0x21-0x7E
, return 1. Otherwise return 0.
is_hex_digit
static method is_hex_digit : int ($code_point : int);
If $character is a hexadecimal digit 0-9a-fA-F
, return 1. Otherwise return 0.
is_lower
static method is_lower : int ($code_point : int);
If the Unicode $code_point is an ASCII lowercase character a-z
, return 1. Otherwise return 0.
is_mulnum_array
static method is_mulnum_array : int ($object : object);
If $object is defined and the type of $object is the multi-numeric array type, return 1. Otherwise return 0.
"is_mulnum_array" in SPVM::Document::NativeAPI is used to check the type.
is_numeric_array
static method is_numeric_array : int ($object : object);
If $object is defined and the type of $object is the numeric array type, return 1. Otherwise return 0.
"is_numeric_array" in SPVM::Document::NativeAPI is used to check the type.
is_object_array
static method is_object_array : int ($object : object);
If $object is defined and the type of $object is an object array type, return 1. Otherwise return 0.
"is_object_array" in SPVM::Document::NativeAPI is used to check the type.
is_perl_space
static method is_perl_space : int ($code_point : int);
If the Unicode $code_point is an Perl ASCII space character 0x09(HT, '\t')
, 0x0A(LF, '\n')
, 0x0C(FF, '\f')
, 0x0D(CR, '\r')
, 0x20(SP, ' ')
, return 1. Otherwise return 0.
Note that prior to Perl v5.18, \s
in ASCII mode did not match the vertical tab 0x0B(VT)
. is_perl_space
is the same as this behavior.
Current Perl \s
in ASCII mode is the same as "is_space".
is_perl_word
static method is_perl_word : int ($code_point : int);
If the Unicode $code_point is an Perl ASCII word character a-zA-Z0-9_
, return 1. Otherwise return 0.
is_pointer_class
static method is_pointer_class : int ($object : object);
If $object is defined and $object is a pointer class, return 1. Otherwise return 0.
"is_pointer_class" in SPVM::Document::NativeAPI is used to check the type.
is_print
static method is_print : int ($code_point : int);
If the Unicode $$code_point
is an ASCII printable character 0x20-0x7E
, return 1. Otherwise return 0.
is_punct
static method is_punct : int ($code_point : int);
If the Unicode $code_point is an ASCII a punctuation character 0x21-0x2F
, 0x3A-0x40
, 0x5B-0x60
, 0x7B-0x7E
, return 1. Otherwise return 0.
is_space
static method is_space : int ($code_point : int);
If the Unicode $code_point is an ASCII a white-space 0x09(HT, '\t')
, 0x0A(LF, '\n')
, 0x0B(VT)
, 0x0C(FF, '\f')
, 0x0D(CR, '\r')
, 0x20(SP, ' ')
return 1. Otherwise return 0.
is_upper
static method is_upper : int ($code_point : int);
If $code_point is an ASCII uppercase character A-Z
, return 1. Otherwise return 0.
is_xdigit
static method is_xdigit : int ($code_point : int);
If $code_point is an ASCII hexadecimal digit 0-9A-Fa-f
, return 1. Otherwise return 0.
join
static method join : string ($separator : string, $strings : string[]);
Concatenates $strings with $separater and return it.
Exceptions:
$strings must be defined. Otherwise an exception is thrown.
$separator must be defined. Otherwise an exception is thrown.
labs
static method labs : long ($value : long);
Returns the absolute value of $value.
lc
static method lc : string ($string : string);
Converts the ASCII uppercase characters A-Z
in $string to the corresponding ASCII lowercase characters a-z
. And return it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
lcfirst
static method lcfirst : string ($string : string);
If the first character of $string is an ASCII uppercase character A-Z
, it is converted to the corresponding ASCII lowercase characters a-z
. And return the converted string.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
look_code_point
static method look_code_point : int ($string : string, $offset_ref : int*);
The same as "get_code_point", but the offset is not updated.
memcpy
static method memcpy : void ($dest : object, $dest_offset : int, $source : object, $source_offset : int, $length : int);
Copies the range of $source to the the range of $dest.
The range of $dest is from $offset to the position proceeded by $length of the destination.
The range of $source is from $offset to the position proceeded by $length of the source.
The unit of $offset and $length is byte
size.
If the range of $source and the range of $dest overlap, the result is not guaranteed.
Exceptions:
$dest must be defined. Otherwise an exception is thrown.
The type of $dest must be the string
type, the numeric array type, or the multi-numeric array type. Otherwise an exception is thrown.
$source must be defined. Otherwise an exception is thrown.
The type of $source must be the string
type, the numeric array type, or the multi-numeric array type. Otherwise an exception is thrown.
$dest must not be a read-only string. Otherwise an exception is thrown.
$length must be greater than or equal to 0. Otherwise an exception is thrown.
$dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
$source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
memmove
static method memmove : void ($dest : object, $dest_offset : int, $source : object, $source_offset : int, $length : int);
The same as "memcpy", but even if the range of $source and the range of $dest overlap, the result is guaranteed.
ord
static method ord : int ($string : string);
The alias for the following code using "get_code_point".
my $offset = 0;
my $code_point = Fn->get_code_point($string, \$offset);
powi
static method powi : int ($base : int, $exponant : int);
Calculates the exponentiation from $base number and $exponant number.
Exceptions:
$exponant number must be greater than or equal to 0. Otherwise an exception is thrown.
If $base number is 0, $exponant number cannnot be 0.
powl
static method powl : long ($base : long, $exponant : long);
Calculates the exponentiation from $base number and $exponant number.
Exceptions:
$exponant number must be greater than or equal to 0. Otherwise an exception is thrown.
If $base number is 0, $exponant number cannnot be 0.
rand
static method rand : double ($seed : int*, $max : int = 1);
Gets a 64bit floating point random number that is greater than or equal to 0 and less than 1 using $seed.
If $max is specified, $max is multiplied to the return value.
The seed is updated.
This method is thread safe.
Examples:
use Sys::Time;
my $seed = (int)Sys::Time->time;
my $rand0 = Fn->rand(\$seed);
my $rand1 = Fn->rand(\$seed);
repeat
static method repeat : double ($string : string, $count : int);
Concatenates $string the number of times specified in $count and return it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$repeat count must be greater than or equal to 0.
Examples:
# "abcabcabc"
my $repeat_string = Fn->repeat("abc", 3);
replace_chars
static method replace_chars : void ($string : mutable string, $from_ch : int, $to_ch : int);
Replaces all characters specified by the second argument in $string with the characters specified by the third argument.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
rindex
static method rindex : int ($string : string, $substring : string, $end : int = -1, $begin : int = 0);
Searches for $substring in the range of $string from $begin to $end.
The search is performed from the end of the range of $string.
If $substring is found, returns the found offset, otherwise returns -1.
If $end is less than 0, $end is set to the length of $string minus 1.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$substring must be defined. Otherwise an exception is thrown.
$begin must be greater than or equal to 0. Otherwise an exception is thrown.
$end must be less than the length of $string.
sizeof_native_int
static method sizeof_native_int : int ();
Returns the native int
size. This is the same value as sizeof(int)
in the C language.
sizeof_native_pointer
static method sizeof_native_pointer : int ();
Returns the native pointer size. This is the same value as sizeof(void*)
in the C language.
shorten
static method shorten : void ($string : mutable string, $length : int32_t);
Shortens $string to $length specified by the argument using "shorten" in SPVM::Document::NativeAPI.
If the length specified by the argument is greater than or equal to the length of the string, nothing is performed.
Exceptions:
$string must be defined.
$length must be greater than or equal to 0. Otherwise an exception is thrown.
shorten_null_char
static method shorten_null_char : void ($string : mutable string);
Shortens $string just before the first null character \0
.
If null characters is not found, do nothing.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
Example:
my $message = (mutable string)copy "foo\0bar";
# "foo"
my $message_shoten = Fn->shorten_null_char($message);
split
static method split : string[] ($separator : string, $string : string, $limit : int = -1);
If $limit is less than 0, split $string by the specific $separator and convert them to an string array and return it.
If $limit is greater than than 0, the limit becomes the length of the maximam separated elements.
Exceptions:
$separator must be defined. Otherwise an exception is thrown.
$string must be defined. Otherwise an exception is thrown.
$limit cannnot be 0. Otherwise an exception is thrown.
substr
static method substr : string ($string : string, $offset : int, $length : int = -1, $replacement : string = undef);
Cuts a substring of $length from $offset of $string, and returns it.
If $length is ommited, $length is the length of $string minus $offset.
If the length is less than 0, the length to the end of the string is calculated from the length of $string and $offset.
Replacement:
If $replacement is given, returns a string that is the replacement string $replacement of $string from $offset to $length.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$offset must be greater than or equal to 0. Otherwise an exception is thrown.
$offset + $length must be less than or equal to the length of $string. Otherwise an exception is thrown.
to_code_points
static method to_code_points : int[] ($string : string)
Converts $string to the Unicode code points, and returns it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$string contains an invalid Unicode code point. Otherwise an exception is thrown.
to_double
static method to_double : double ($string : string);
Converts $string to the double
value using strtod
in the C language.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$string must be the string that can be parsed as a double number. Otherwise an exception is thrown.
$string must be a double number in $correct range. Otherwise an exception is thrown.
Examples:
my $string = "1.25";
my $num = Fn->to_double($string);
to_float
static method to_float : float ($string : string);
Converts $string to the double
value using strtof
in the C language.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$string must be the string that can be parsed as a float number. Otherwise an exception is thrown.
$string must be a float number in $correct range. Otherwise an exception is thrown.
Examples:
my $string = "1.25";
my $num = Fn->to_float($string);
to_int
static method to_int : int ($string : string, $digit : int);
The alias for the following code using "to_int_with_base".
my $ret = Fn->to_int_with_base($string, 10);
to_int_with_base
Converts $string to the int
value with $digit using strtol
in the C language.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$string must be the string that can be parsed as an int number. Otherwise an exception is thrown.
$string must be an int number in $correct range. Otherwise an exception is thrown.
Examples:
my $string = "-2147483648";
my $num = Fn->to_int_with_base($string, 10);
to_long
static method to_long : long ($string : string);
The alias for the following code using "to_long_with_base".
my $ret = Fn->to_long_with_base($string, 10);
to_long_with_base
static method to_long_with_base : long ($string : string, $digit : int);
Converts $string to the long
value with $digit using strtoll
in the C language.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$digit must be one of 2, 8, 10, or 16. Otherwise an exception is thrown.
$string must be the string that can be parsed as a long number. Otherwise an exception is thrown.
$string must be a long number in $correct range. Otherwise an exception is thrown.
Examples:
my $string = "-9223372036854775808";
my $num = Fn->to_long_with_base($string, 10);
to_lower
static method to_lower : int ($code_point : int);
If $code_point is the ASCII uppercase character A-Z
, it is converted to the corresponding ASCII lowercase character a-z
.
If $code_point is not an ASCII uppercase character, return itself.
to_upper
static method to_upper : int ($code_point : int);
If $code_point is the ASCII lowercase character a-z
, it is converted to the corresponding ASCII uppercase character A-Z
.
If $code_point is not an ASCII lowercase character, return itself.
to_utf8_chars
static method to_utf8_chars : string[] ($string : string);
Converts $string to UTF-8 characters, and returns it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$string contains an invalid Unicode code point. Otherwise an exception is thrown.
Examples:
my $string = "あいうa";
# ["あ", "い", "う", "a"]
my $utf8_chars = Fn->to_utf8_chars($string);
tr
static method tr : string ($string : string, $pattern : string, $replace : string)
Replaced the range of $pattern with the range of $replace in a $string and returns a replaced string.
The range must be the format a-z
or a
. If the format is a
, it is converted to a-a
.
# The range format examples
"a-z"
"0-9"
"a"
"5"
"0-9"
"あ-ん"
Exceptions:
$string must be defined. Otherwise an exception is thrown.
$pattern must be defined. Otherwise an exception is thrown.
$replace must be defined. Otherwise an exception is thrown.
If $string contains an invalid Unicode code point, an exception is thrown.
The range format of the (pattern|replace) cannnot be contain an invalid Unicode code point. If so, an exception is thrown. If so, an exception is thrown.
The second character ot the range format of the (pattern|replace) must be \"-\". Otherwise an exception is thrown.
The range format of the (pattern|replace) must be 1 or 3 characters. Otherwise an exception is thrown.
The exceptions of the "get_code_point"" in " method can be thrown.
Examples:
{
my $string = "0123456789";
my $pattern = "0-9";
my $replace = "0-9";
# "0123456789"
my $ret = Fn->tr($string, $pattern, $replace);
}
{
my $string = "abcd";
my $pattern = "a-c";
my $replace = "x-z";
# "xyzd"
my $ret = Fn->tr($string, $pattern, $replace);
}
}
trim
static method trim : string ($string : string);
Removes the right and left spaces of $string and return it.
The removed spaces is the same as the spaces "is_space" method returns 1.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
uc
static method uc : string ($string : string);
Converts the ASCII lowercase characters a-z
in $string to the corresponding ASCII uppercase characters A-Z
. And return it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
ucfirst
static method ucfirst : string ($string : string);
If the first character of $string is an ASCII lowercase characters a-z
, it is converted to the corresponding ASCII uppercase character A-Z
. And return the converted string.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
utf8_length
static method utf8_length : int ($string : string)
Gets the length as a UTF-8 string from $string, and returns it.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
If $string contains an invalid Unicode code point, an exception is thrown.
Examples:
# 3
my $utf8_length = Fn->utf8_length("あいう");
utf8_substr
static method utf8_substr : string ($string : string, $utf8_offset : int, $utf8_length : int = -1);
Gets the substring from $string. The extracting range of the string is from $utf8_offset to the position proceeded by $utf8_length, and returns it.
If the length is less than 0, the length to the end of the string is calculated from the length of $string and $utf8_offset.
Exceptions:
$string must be defined. Otherwise an exception is thrown.
If $string contains an invalid Unicode code point, an exception is thrown.
$utf8_offset + $utf8_length must be less than or equal to the UTF-8 length of $string. Otherwise an exception is thrown.
Examples:
# "いえ"
my $utf8_substr = Fn->utf8_substr("あいうえ", 1, 2);
merge_options
static method merge_options : object[] ($options1 : object[], $options2 : object[]);
Creates a new any object array merging $options1 and $options2, and returns it.
If $options2 contains the same key of $options1, the key of $options1 is overwritten by the key of $options2.
Exceptions:
$options1 must be defined. Otherwise an exception is thrown.
$options2 must be defined. Otherwise an exception is thrown.
The length of $options1 must be an even number. Otherwise an exception is thrown.
The length of $options2 must be an even number. Otherwise an exception is thrown.
The key of $options1 must be defined. Otherwise an exception is thrown.
The key of $options1 must be the string type. Otherwise an exception is thrown.
The key of $options2 must be defined. Otherwise an exception is thrown.
The key of $options2 must be the string type. Otherwise an exception is thrown.
Exceptions of the Hash class can be thrown.
Examples:
my $merged_options = Fn->merge_options({foo => 1, bar => 2}, {baz => 5});
object_to_int
static method object_to_int : int ($object : object);
Converts the address of $object to a value of the int type, and returns it.
get_spvm_version_string
static method get_spvm_version_string : string ();
Returns the the version string of the SPVM language.
get_spvm_version_string
static method get_spvm_version_string : string ();
Returns the the version string of the SPVM language.
get_spvm_version_number
static method get_spvm_version_number : double ();
Returns the version number of the SPVM language.
get_version_number
static method get_version_number : double ($basic_type_name : string);
Returns the version number of a class.
Exceptions:
$basic_type_name must be defined. Otherwise an exception is thrown.
The class specified by $basic_type_name must be loaded. Otherwise an exception is thrown.
defer
static method defer : Scope::Guard ($callback : Callback);
Calls the new method in the Scope::Guard class and return its return value.
get_memory_blocks_count
static method get_memory_blocks_count : int ();
Gets the count of the memory blocks allocated by the new_memory_block native API.
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License