Cattle.Program

g Cattle.Program Cattle.Program GObject.Object GObject.Object GObject.Object->Cattle.Program

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

get_input ()

get_instructions ()

load (buffer)

set_input (input)

set_instructions (instructions)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

input

Cattle.Buffer

r/w

Get/set program’s input

instructions

Cattle.Instruction

r/w

Get/set instructions

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Cattle.Program(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Cattle.ProgramClass

Opaque data structure representing a program. It should never be accessed directly.

classmethod new()[source]
Returns:

a new Cattle.Program

Return type:

Cattle.Program

Create a new Cattle.Program.

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.

get_input()[source]
Returns:

input for self

Return type:

Cattle.Buffer

Get the input for self. See Cattle.Program.set_input().

get_instructions()[source]
Returns:

the first instruction in self

Return type:

Cattle.Instruction

Get the instructions for self. See Cattle.Program.load() and Cattle.Program.set_instructions().

load(buffer)[source]
Parameters:

buffer (Cattle.Buffer) – a Cattle.Buffer containing the code

Raises:

GLib.Error

Returns:

True on success, False otherwise

Return type:

bool

Load self 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 Cattle.Error enumeration.

set_input(input)[source]
Parameters:

input (Cattle.Buffer) – input for self

Set the input for self.

If the size of input is zero, the program’s input will be retrieved at runtime.

set_instructions(instructions)[source]
Parameters:

instructions (Cattle.Instruction) – instructions for self

Set the instructions for self.

You shouldn’t usually need to use this: see Cattle.Program.load() for the standard way to load a program.

Property Details

Cattle.Program.props.input
Name:

input

Type:

Cattle.Buffer

Default Value:

None

Flags:

READABLE, WRITABLE

Input for the program, or None if no input was available at the time of loading.

Changes to this property are not notified.

Cattle.Program.props.instructions
Name:

instructions

Type:

Cattle.Instruction

Default Value:

None

Flags:

READABLE, WRITABLE

Instructions for the program.

Changes to this property are not notified.