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

em.utility

Class EM_INTEGER_ARRAY


Direct ancestors

EWG_ARRAY

Creation

Features

Invariants

indexing

description

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

date

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

revision

$Revision: 1.2 $

class

EM_INTEGER_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)

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