| Top |
| CattleTape * | cattle_tape_new () |
| void | cattle_tape_set_current_value () |
| gchar | cattle_tape_get_current_value () |
| void | cattle_tape_increase_current_value () |
| void | cattle_tape_increase_current_value_by () |
| void | cattle_tape_decrease_current_value () |
| void | cattle_tape_decrease_current_value_by () |
| void | cattle_tape_move_left () |
| void | cattle_tape_move_left_by () |
| void | cattle_tape_move_right () |
| void | cattle_tape_move_right_by () |
| gboolean | cattle_tape_is_at_beginning () |
| gboolean | cattle_tape_is_at_end () |
| void | cattle_tape_push_bookmark () |
| gboolean | cattle_tape_pop_bookmark () |
A CattleTape represents an infinte-length memory tape, which is used by a CattleInterpreter to store its data. The tape contains a virtually infinte number of memory cells, each one able to store a single ASCII character.
A tape supports three kinds of operations: reading the value of the current cell, updating the value of the current cell (either by increasing/decreasing it or by setting it to a certain value), and moving the current cell pointer (either to the left or to the right).
The tape grows automatically as more cells are needed, the only limit
being the amount of available memory. It is possible to check if the
current cell is at the beginning or at the end of the tape using
cattle_tape_is_at_beginning() and cattle_tape_is_at_end().
void cattle_tape_set_current_value (CattleTape *tape,gchar value);
Set the value of the current cell.
Accepted values are ASCII values or EOF.
gchar
cattle_tape_get_current_value (CattleTape *tape);
Get the value of the current cell. See
cattle_tape_set_current_value().
void
cattle_tape_increase_current_value (CattleTape *tape);
Increase the value in the current cell by one.
If the value in the current cell has ASCII code 127, the new value will have ASCII code 0.
void cattle_tape_increase_current_value_by (CattleTape *tape,gint value);
Increase the value in the current cell by value
.
The value is wrapped if needed to keep it in the ASCII code.
Increasing the value this way is much faster than calling
cattle_tape_increase_current_value() multiple times.
void
cattle_tape_decrease_current_value (CattleTape *tape);
Decrease the value in the current cell by one.
If the value in the current cell has ASCII value 0, the new value will have ASCII value 127.
void cattle_tape_decrease_current_value_by (CattleTape *tape,gint value);
Decrease the value in the current cell by value
.
The value is wrapped if needed to keep it in the ASCII code.
Decreasing the value this way is much faster than calling
cattle_tape_decrease_current_value() multiple times.
void
cattle_tape_move_left (CattleTape *tape);
Move tape
one cell to the left.
If there are no memory cells on the left of the current one, one will be created on the fly.
void cattle_tape_move_left_by (CattleTape *tape,gint steps);
Move tape
steps
cells to the left.
Moving this way is much faster than calling
cattle_tape_move_left() multiple times.
void
cattle_tape_move_right (CattleTape *tape);
Move tape
one cell to the right.
If there are no memory cells on the right of the current one, one will be created on the fly.
void cattle_tape_move_right_by (CattleTape *tape,gint steps);
Move tape
steps
cells to the right.
Moving this way is much faster than calling
cattle_tape_move_right() multiple times.
gboolean
cattle_tape_is_at_beginning (CattleTape *tape);
Check if the current cell is the first one of tape
.
Since the tape grows automatically as more cells are needed, it is possible to move left from the first cell.
gboolean
cattle_tape_is_at_end (CattleTape *tape);
Check if the current cell is the last one of tape
.
Since the tape grows automatically as more cells are needed, it is possible to move right from the last cell.
void
cattle_tape_push_bookmark (CattleTape *tape);
Create a bookmark to the current tape position and save it on the bookmark stack.
gboolean
cattle_tape_pop_bookmark (CattleTape *tape);
Restore the previously-saved tape position.
See cattle_tape_push_bookmark().
“current-value” property“current-value” gchar
Value of the current cell.
Changes to this property are not notified.
Flags: Read / Write
Allowed values: >= -1
Default value: 0