NAME ^

classes/perlstring.pmc - Perl String

DESCRIPTION ^

PerlString extends perlscalar to provide Perl string behaviour.

Methods ^

void *invoke(void *next)

Pythonic object constructor. SELF is a PerlString Class object. Return a new str object according to 2.1. Built-in Functions.

void init()

Initializes the string.

void mark()

Marks the string as live.

PMC *clone()

Creates and returns a clone of the string.

INTVAL get_integer()

Returns the integer value of the string.

FLOATVAL get_number()

Returns the floating-point value for the string.

BIGNUM *get_bignum()

Unimplemented. Returns NULL.

INTVAL get_bool()

Returns the boolean value of the string.

STRING *get_repr()

Returns pythons string repr (w/o any escaping, just single quotes around)

INTVAL is_same(PMC *other)

Returns whether the string is the same as *other.

void set_integer_native(INTVAL value)

Morphs the string to a PerlInt and sets its value to value.

void set_number_native(FLOATVAL value)

Morphs the string to a PerlNum and sets its value to value.

void set_string_native(STRING *value)

Sets the string's value to the value of the specified Parrot string.

void assign_string_native(STRING *value)

Assign a copy of the passed string value.

void set_string_same(PMC *value)

Sets the string's value to the value of the specified PerlString.

void add(PMC *value, PMC *dest)

Adds *value to the string and returns the result in *dest.

When Python mode is enabled does concat :(

void subtract(PMC *value, PMC *dest)

Subtracts *value from the string and returns the result in *dest.

void multiply(PMC *value, PMC *dest)

Multiplies the string by *value and returns the result in *dest.

void divide(PMC *value, PMC *dest)

Divides the string by *value and returns the result in *dest.

void modulus(PMC *value, PMC *dest)

Calculates the string mod *value and returns the result in *dest.

When Python mode is enabled does sprintf :(

String Bitwise Operations ^

void bitwise_ors(PMC *value, PMC *dest)

void bitwise_ors_str(STRING *value, PMC *dest)

Calculates the string bitwise OR for the string and *value and returns the result in *dest.

void bitwise_xors(PMC *value, PMC *dest)

void bitwise_xors_str(STRING *value, PMC *dest)

Calculates the string bitwise XOR for the string and *value and returns the result in *dest.

void bitwise_ands(PMC *value, PMC *dest)

void bitwise_ands_str(STRING *value, PMC *dest)

Calculates the string bitwise AND for the string and *value and returns the result in *dest.

void bitwise_nots(PMC *dest)

Calculates the string bitwise NOT for the string and returns the result in *dest.

void concatenate(PMC *value, PMC *dest)

Concatenates the string and the stringified form of *value and return the result in *dest, morphing it to a PerlString if required.

void concatenate_str(STRING *value, PMC *dest)

Concatenates the string and *value and returns the result in *dest.

INTVAL is_equal(PMC *value)

The == operation.

INTVAL cmp(PMC *value)

Returns the result of comparing the string with *value.

void repeat(PMC *value, PMC *dest)

Returns in *dest the string repeated *value times.

void repeat_int(INTVAL value, PMC *dest)

Returns in *dest the string repeated value times.

void increment()

void decrement()

These two methods are partially implemented. They should provide Perl 5 like string increment/decrement.

void substr(INTVAL offset, INTVAL length, PMC *dest)

Returns in *dest the length character substring of the string starting at offset.

STRING *substr_str(INTVAL offset, INTVAL length)

Returns the length character substring of the string starting at offset.

Iterator Interface ^

PMC *slice (PMC *key, INTVAL f)

Return a new iterator for the slice PMC key if f==0.

Return a new pythonic slice if f == 1.

PMC *get_iter (PMC *key)

Return a new iterator for this string.

INTVAL elements ()

Return length of the string.

STRING *get_string_keyed(PMC *key)

PMC *get_pmc_keyed(PMC *key)

Returns the string value for SELF[key].

INTVAL get_integer_keyed(PMC *key)

Returns the integer value for *key.

void freeze(visit_info *info)

Used to archive the string.

void thaw(visit_info *info)

Used to unarchive the string.


parrot