Top |
A CattleProgram represents a complete Brainfuck program, that is, the instructions to be executed and possibly its input.
The input for a program can optionally be specified in the source file, and it's separated from the program code by a bang (!) symbol. For example, given the following input:
1 |
,+.!sometext |
the program's code is ",+." while the program's input is "sometext".
Any Brainfuck instruction after the bang symbol is considered part of the input, and as such is not executed. Subsequent bang symbols are also considered part of the input.
CattleProgram *
cattle_program_new (void
);
Create a new CattleProgram.
A single instance of a program can be shared between multiple interpreters, as long as the object is not modified after it has been initialized.
gboolean cattle_program_load (CattleProgram *program
,CattleBuffer *buffer
,GError **error
);
Load program
from buffer
.
The buffer can optionally contain also the input for the program: in that case, the input must be separated from the code by a bang (!) character.
In case of failure, error
is filled with detailed information.
The error domain is CATTLE_ERROR
, and the error code is from the
CattleError enumeration.
program |
||
buffer |
a CattleBuffer containing the code. |
[transfer full] |
error |
return location for a GError. |
[allow-none] |
void cattle_program_set_instructions (CattleProgram *program
,CattleInstruction *instructions
);
Set the instructions for program
.
You shouldn't usually need to use this: see cattle_program_load()
for the standard way to load a program.
CattleInstruction *
cattle_program_get_instructions (CattleProgram *program
);
Get the instructions for program
.
See cattle_program_load()
and cattle_program_set_instructions()
.
void cattle_program_set_input (CattleProgram *program
,CattleBuffer *input
);
Set the input for program
.
If the size of input
is zero, the program's input will be retrieved
at runtime.
CattleBuffer *
cattle_program_get_input (CattleProgram *program
);
Get the input for program
.
See cattle_program_set_input()
.
“input”
property“input” CattleBuffer *
Input for the program, or NULL
if no input was available
at the time of loading.
Changes to this property are not notified.
Owner: CattleProgram
Flags: Read / Write
“instructions”
property“instructions” CattleInstruction *
Instructions for the program.
Changes to this property are not notified.
Owner: CattleProgram
Flags: Read / Write