Cattle.Interpreter

g Cattle.Interpreter Cattle.Interpreter GObject.Object GObject.Object GObject.Object->Cattle.Interpreter

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

feed (input)

get_configuration ()

get_program ()

get_tape ()

run ()

set_configuration (configuration)

set_debug_handler (handler, *user_data)

set_input_handler (handler, *user_data)

set_output_handler (handler, *user_data)

set_program (program)

set_tape (tape)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

configuration

Cattle.Configuration

r/w

Get/set interpreter’s configuration

program

Cattle.Program

r/w

Get/set interpreter’s program

tape

Cattle.Tape

r/w

Get/set interpreter’s tape

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Cattle.Interpreter(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Cattle.InterpreterClass

Opaque data structure representing an interpreter. It should never be accessed directly.

classmethod new()[source]
Returns:

a new Cattle.Interpreter

Return type:

Cattle.Interpreter

Create and initialize a new interpreter.

feed(input)[source]
Parameters:

input (Cattle.Buffer) – more input to be used by self

Feed self with more input.

This method is meant to be used inside an input handler assigned to self; calling it in any other context is pointless, since the input is reset each time Cattle.Interpreter.run() is called.

get_configuration()[source]
Returns:

configuration for self

Return type:

Cattle.Configuration

Get the configuration for self. See Cattle.Interpreter.set_configuration().

get_program()[source]
Returns:

the program for self

Return type:

Cattle.Program

Get the program for self. See Cattle.Interpreter.set_program().

get_tape()[source]
Returns:

the memory tape for self

Return type:

Cattle.Tape

Get the memory tape used by self. See Cattle.Interpreter.set_tape().

run()[source]
Raises:

GLib.Error

Returns:

True on success, False otherwise

Return type:

bool

Make the interpreter run the loaded program.

set_configuration(configuration)[source]
Parameters:

configuration (Cattle.Configuration) – configuration for self

Set the configuration for self.

The same configuration can be used for several interpreters, but modifying it after it has been assigned to an interpreter may result in undefined behaviour, and as such is discouraged.

set_debug_handler(handler, *user_data)[source]
Parameters:

Set the debug handler for self.

The handler will be invoked every time self needs to perform a debug action; if handler is None, the default debug handler will be used.

set_input_handler(handler, *user_data)[source]
Parameters:

Set the input handler for self.

The handler will be invoked every time self needs to perform an input action; if handler is None, the default input handler will be used.

set_output_handler(handler, *user_data)[source]
Parameters:

Set the output handler for self.

The handler will be invoked every time self needs to perform an output action; if handler is None, the default output handler will be used.

set_program(program)[source]
Parameters:

program (Cattle.Program) – a Cattle.Program

Set the program to be executed by self.

A single program can be shared between multiple interpreters, as long as care is taken not to modify it after it has been assigned to any of them.

set_tape(tape)[source]
Parameters:

tape (Cattle.Tape) – a Cattle.Tape

Set the memory tape used by self.

Property Details

Cattle.Interpreter.props.configuration
Name:

configuration

Type:

Cattle.Configuration

Default Value:

None

Flags:

READABLE, WRITABLE

Configuration used by the interpreter.

Changes to this property are not notified.

Cattle.Interpreter.props.program
Name:

program

Type:

Cattle.Program

Default Value:

None

Flags:

READABLE, WRITABLE

Program executed by the interpreter.

Changes to this property are not notified.

Cattle.Interpreter.props.tape
Name:

tape

Type:

Cattle.Tape

Default Value:

None

Flags:

READABLE, WRITABLE

Tape used to store the data needed by the program.

Changes to this property are not notified.