Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.utility

Class EM_INT8_ARRAY


Direct ancestors

EWG_ARRAY

Creation

Features

Invariants

indexing

description

Class for wrapping C int8 arrays for passing them to SDL.

date

$Date: 2005/10/23 10:36:32 $

revision

$Revision: 1.6 $

class

EM_INT8_ARRAY

inherit

EWG_ARRAY

create

make_new_unshared (a_count: INTEGER)

-- Create new C array wrapper with a_count items
-- each item_size bytes big.
-- Allocates as much new memory as the array needs.
-- 'unshared' means if the Current object
-- gets collected by the garbage collector,
-- the memory allocated for the array will
-- be freed as well.

-- (From EWG_ARRAY)

require
a_count_greater_zero: a_count > 0
ensure
count_set: count = a_count
item_not_default_pointer: array_address /= default_pointer
is_not_shared: not is_shared
make_new_shared (a_count: INTEGER)

-- Create new C array wrapper with a_count items
-- each item_size bytes big.
-- Allocates as much new memory as the array needs.
-- 'shared' means if the Current object
-- gets collected by the garbage collector,
-- the memory allocated for the array will
-- not be freed as well.

-- (From EWG_ARRAY)

require
a_count_greater_zero: a_count > 0
ensure
count_set: count = a_count
item_not_default_pointer: array_address /= default_pointer
is_shared: is_shared
make_unshared (a_item: POINTER; a_count: INTEGER)

-- Create a new array wrapper to a given C array starting at a_item
-- with a_count items each item item_size big.
-- 'unshared' means if the Current object
-- gets collected by the garbage collector,
-- the memory allocated for the array will
-- be freed as well.

-- (From EWG_ARRAY)

require
a_count_greater_zero: a_count > 0
ensure
count_set: count = a_count
item_not_default_pointer: array_address /= default_pointer
is_not_shared: not is_shared
make_shared (a_item: POINTER; a_count: INTEGER)

-- Create a new array wrapper to a given C array starting at a_item
-- with a_count items each item item_size big.
-- 'shared' means if the Current object
-- gets collected by the garbage collector,
-- the memory allocated for the struct will
-- not be freed as well.

-- (From EWG_ARRAY)

require
a_count_greater_zero: a_count > 0
ensure
count_set: count = a_count
item_not_default_pointer: array_address /= default_pointer
is_shared: is_shared

feature {ANY} -- Access

array_address: POINTER

-- C Address of the array (which is
-- also the address of the first item
-- in the array)

-- (From EWG_ARRAY)

copy_from (other: like current)

-- copy from other

require
other_not_to_big: other.count <= count
copy_from_count (other: like current; cnt: INTEGER)

-- copy from other cnt items

require
current_big_enough: count >= cnt
other_big_enough: other.count >= cnt
copy_from_position (other: like current; position: INTEGER)

-- copy from other starting at position

require
position_valid: position >= 0 and position < other.count
other_not_to_big: other.count <= position + count
copy_from_position_count (other: like current; position, cnt: INTEGER)

-- copy from other starting at position cnt items

require
position_valid: position >= 0 and position < other.count
other_big_enough: other.count >= position + cnt
current_big_enough: count >= cnt
copy_from_position_to (other: like current; position, to_position: INTEGER)

-- copy from other starting at position to to_position

require
position_valid: position >= 0 and position < other.count
to_position_valid: to_position >= 0 and to_position < count
other_not_to_big: other.count + to_position <= count + position
copy_from_position_to_count (other: like current; position, to_position, cnt: INTEGER)

-- copy from other starting at position to to_position cnt items

require
position_valid: position >= 0 and position < other.count
to_position_valid: to_position >= 0 and to_position < count
other_big_enough: other.count >= position + cnt
current_big_enough: count >= to_position + cnt
copy_from_to (other: like current; to_position: INTEGER)

-- copy from other to starting position to_position

require
to_position_valid: to_position >= 0 and to_position < count
other_not_to_big: other.count + to_position <= count
copy_from_to_count (other: like current; to_position, cnt: INTEGER)

-- copy from other to starting position to_position cnt items

require
to_position_valid: to_position >= 0 and to_position < count
other_big_enough: other.count >= cnt
current_big_enough: count >= to_position + cnt
count: INTEGER

-- Number of items in the array.
-- NOTE: This is a fixed size array.

-- (From EWG_ARRAY)

exists: BOOLEAN

-- Does array_address point to a valid C array ?

-- (From EWG_ARRAY)

is_shared: BOOLEAN

-- Is the contents of item referenced by other C or Eiffel code?
-- If is_shared is True then when the current object will be
-- collected by the garbage collector, the wrapped array will
-- also be freed.
-- This is a good idea, only if you can be sure that when the
-- Eiffel object gets collected, the C side does not have a reference
-- to the wrapped array anymore.

-- (From EWG_ARRAY)

require
exists: exists
is_valid_index (i: INTEGER): BOOLEAN

-- Is i a valid index for this array ?

-- (From EWG_ARRAY)

item (i: INTEGER): INTEGER

-- Return i-th item

require
exists: exists
valid_index: is_valid_index (i)
put (v: INTEGER; i: INTEGER)

-- Replace i-th entry by v

require
exists: exists
valid_index: is_valid_index (i)
ensure
integer_set: item (i) = v

invariant

-- From EWG_ARRAY
managed_data_not_void: managed_data /= Void
managed_capacity_equals_size_of_array: managed_data.capacity = count * item_size
count_greater_zero: count > 0

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end