+
Point of view
All features
deferred class C_ARRAY [ITEM_ -> C_STRUCT]
Summary
An array of wrapped item which is also a wrapper to a C array of pointers of item's struct. For example a C_ARRAY[GTK_BUTTON] wraps a GtkButton** array.
copyright
Copyright (C) 2006-2017: Paolo Redaelli This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Direct parents
Inherit list: WRAPPER_COLLECTION
Insert list: EXCEPTIONS
Known children
Inherit list: NULL_TERMINATED_C_ARRAY
Class invariant
Overview
Features
Creation
{}
{ANY}
Writing:
{ANY}
Adding:
{ANY}
  • add_first (element: ITEM_)
    Performance: O(count), not counting the eventual reallocation.
  • add_last (element: ITEM_)
    Performance: O(1), not counting the eventual reallocation.
  • add (element: ITEM_, index: INTEGER_32)
    Performance: O(count-index), not counting the eventual reallocation
Modification:
{ANY}
  • copy (other: C_ARRAY [ITEM_ -> C_STRUCT])
    Reinitialize by copying all the items of other.
  • force (element: ITEM_, index: INTEGER_32)
    Make element the item at index, enlarging the collection if necessary (new bounds except index are initialized with default values).
  • from_collection (model: COLLECTION[ITEM_])
    Initialize the current object with the contents of model.
Removing:
{ANY}
Looking and Searching:
{ANY}
Looking and comparison:
{ANY}
Other features:
{ANY}
  • replace_all (old_value: ITEM_, new_value: ITEM_)
    Replace all occurrences of the element old_value by new_value using is_equal for comparison.
  • fast_replace_all (old_value: ITEM_, new_value: ITEM_)
    Replace all occurrences of the element old_value by new_value using basic = for comparison.
  • slice (min: INTEGER_32, max: INTEGER_32): C_ARRAY [ITEM_ -> C_STRUCT]
    New collection consisting of items at indexes in [min..max].
  • reverse
    Reverse the order of the elements.
struct_size: INTEGER
{ANY}
Implementation
{C_ARRAY, WRAPPER_HANDLER}
Implement manifest generic creation (very low-level):
{}
TODO: unimplemented
{ANY}
Implementation
{WRAPPER, WRAPPER_HANDLER}
Accessing:
{ANY}
Writing:
{ANY}
Adding:
{ANY}
Looking and Searching:
{ANY}
Looking and comparison:
{ANY}
Other features:
{ANY}
Implement manifest generic creation:
{}
{ANY}
Other features:
{ANY}
Agent-based features:
{ANY}
Printing:
{ANY}
{ANY}
{}
Agent-based features:
{ANY}
{}
Indexing:
{ANY}
Implementation
{WRAPPER, WRAPPER_HANDLER}
  • wrapper_or_void (a_pointer: POINTER): ITEM_
    A wrapper for a_pointer or Void if a_pointer default_pointer (NULL in C).
Utility features
{}
Wrapper related exceptions
{}
Various exceptions codes:
{ANY}
{ANY}
Status report:
{ANY}
Basic operations:
{ANY}
  • die (code: INTEGER_32)
    Terminate execution with exit status code, without triggering an exception.
  • raise (name: STRING)
    Raise a developer exception of name name.
  • throw (a_exception: EXCEPTION)
Non-Standard Extensions:
{ANY}
{}
from_external_array (an_array: POINTER, a_length: INTEGER_32)
effective procedure
{}
with_capacity (a_capacity: INTEGER_32)
effective procedure
{}
item (i: INTEGER_32): ITEM_
effective function
{ANY}
Item at the corresponding index i.
first: ITEM_
effective function
{ANY}
The very first item.
last: ITEM_
effective function
{ANY}
The last item.
put (element: ITEM_, i: INTEGER_32)
effective procedure
{ANY}
Make element the item at index i.
set_all_with (v: ITEM_)
effective procedure
{ANY}
Set all items with value v.
add_first (element: ITEM_)
effective procedure
{ANY}
Performance: O(count), not counting the eventual reallocation.
add_last (element: ITEM_)
effective procedure
{ANY}
Performance: O(1), not counting the eventual reallocation.
add (element: ITEM_, index: INTEGER_32)
effective procedure
{ANY}
Performance: O(count-index), not counting the eventual reallocation
copy (other: C_ARRAY [ITEM_ -> C_STRUCT])
effective procedure
{ANY}
Reinitialize by copying all the items of other.
force (element: ITEM_, index: INTEGER_32)
effective procedure
{ANY}
Make element the item at index, enlarging the collection if necessary (new bounds except index are initialized with default values).
from_collection (model: COLLECTION[ITEM_])
effective procedure
{ANY}
Initialize the current object with the contents of model.
remove_first
effective procedure
{ANY}
Performance: O(count)
remove_head (n: INTEGER_32)
effective procedure
{ANY}
Performance: O(upper-n)
remove (index: INTEGER_32)
effective procedure
{ANY}
Performance: O(count)
remove_last
effective procedure
{ANY}
Performance: O(1)
remove_tail (n: INTEGER_32)
effective procedure
{ANY}
Performance: O(n)
clear_count
effective procedure
{ANY}
Discard all items (is_empty is True after that call).
clear_count_and_capacity
effective procedure
{ANY}
Instead of releasing the memory, it is reallocated with with 2 elements.
first_index_of (element: ITEM_): INTEGER_32
effective function
{ANY}
Give the index of the first occurrence of element using is_equal for comparison.
index_of (element: ITEM_, start_index: INTEGER_32): INTEGER_32
effective function
{ANY}
Using is_equal for comparison, gives the index of the first occurrence of element at or after start_index.
reverse_index_of (element: ITEM_, start_index: INTEGER_32): INTEGER_32
effective function
{ANY}
Using is_equal for comparison, gives the index of the first occurrence of element at or before start_index.
fast_first_index_of (element: ITEM_): INTEGER_32
effective function
{ANY}
Note: comparison is done using the address of the wrapped structure.
fast_index_of (element: ITEM_, start_index: INTEGER_32): INTEGER_32
effective function
{ANY}
Note: comparison is done using the address of the wrapped structure.
fast_reverse_index_of (element: ITEM_, start_index: INTEGER_32): INTEGER_32
effective function
{ANY}
Note: comparison is done using the address of the wrapped structure
is_equal (other: C_ARRAY [ITEM_ -> C_STRUCT]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower, upper, and items?
all_default: BOOLEAN
effective function
{ANY}
Do all items have their type's default value?
occurrences (element: ITEM_): INTEGER_32
effective function
{ANY}
Number of occurrences of element using is_equal for comparison.
fast_occurrences (element: ITEM_): INTEGER_32
effective function
{ANY}
Number of occurrences of element using basic its handle (or default_pointer) for comparison.
replace_all (old_value: ITEM_, new_value: ITEM_)
effective procedure
{ANY}
Replace all occurrences of the element old_value by new_value using is_equal for comparison.
fast_replace_all (old_value: ITEM_, new_value: ITEM_)
effective procedure
{ANY}
Replace all occurrences of the element old_value by new_value using basic = for comparison.
slice (min: INTEGER_32, max: INTEGER_32): C_ARRAY [ITEM_ -> C_STRUCT]
effective function
{ANY}
New collection consisting of items at indexes in [min..max].
reverse
effective procedure
{ANY}
Reverse the order of the elements.
count: INTEGER_32
effective function
{ANY}
Number of available items in the hoard.
upper: INTEGER_32
writable attribute
{ANY}
Maximum index.
lower: INTEGER_32
is 0
constant attribute
{ANY}
Minimum index.
is_empty: BOOLEAN
effective function
{ANY}
Is the hoard empty ?
See also count.
new_iterator: ITERATOR[ITEM_]
effective function
{ANY}
as_c_array: NATIVE_ARRAY[POINTER]
effective function
{ANY}
Current collection as a C array meant to be passed to C functions expectiong an array of wrapped items.
writable attribute
capacity: INTEGER_32
writable attribute
manifest_make (needed_capacity: INTEGER_32)
effective procedure
{}
Manifest creation of a LLVM_TYPE_ARRAY
manifest_put (index: INTEGER_32, element: ITEM_)
effective procedure
{}
clear_all
effective procedure
{ANY}
fast_has (an_item: ITEM_): BOOLEAN
effective function
{ANY}
has (an_item: ITEM_): BOOLEAN
effective function
{ANY}
swap (i1: INTEGER_32, i2: INTEGER_32)
effective procedure
{ANY}
append_collection (another: COLLECTION[ITEM_])
effective procedure
{ANY}
wrapper (a_pointer: POINTER): ITEM_
deferred function
The wrapper for a_pointer.
infix "@" (i: INTEGER_32): E_
frozen
effective function
{ANY}
The infix notation which is actually just a synonym for item.
set_slice_with (v: ANY, lower_index: INTEGER_32, upper_index: INTEGER_32)
effective procedure
{ANY}
Set all items in range [lower_index .. upper_index] with v.
append_traversable (other: TRAVERSABLE[E_])
effective procedure
{ANY}
Append other to Current.
last_index_of (element: ANY): INTEGER_32
effective function
{ANY}
Using is_equal for comparison, gives the index of the last occurrence of element at or before upper.
fast_last_index_of (element: ANY): INTEGER_32
effective function
{ANY}
Using basic = for comparison, gives the index of the last occurrence of element at or before upper.
fast_is_equal (other: C_ARRAY [ITEM_ -> C_STRUCT]): BOOLEAN
deferred function
{ANY}
Do both collections have the same lower, upper, and items?
is_equal_map (other: C_ARRAY [ITEM_ -> C_STRUCT]): BOOLEAN
effective function
{ANY}
Do both collections have the same lower, upper, and items?
same_items (other: COLLECTION[E_]): BOOLEAN
effective function
{ANY}
Do both collections have the same items?
move (lower_index: INTEGER_32, upper_index: INTEGER_32, distance: INTEGER_32)
effective procedure
{ANY}
Move range lower_index ..
manifest_semicolon_check: BOOLEAN
is False
constant attribute
{}
enumerate: ENUMERATE[E_]
effective function
{ANY}
get_new_iterator: ITERATOR[E_]
frozen
effective function
{ANY}
for_each (action: PROCEDURE[TUPLE[TUPLE 1[E_]]])
effective procedure
{ANY}
Apply action to every item of Current.
for_all (test: FUNCTION[TUPLE[TUPLE 1[E_]]]): BOOLEAN
effective function
{ANY}
Do all items satisfy test?
exists (test: FUNCTION[TUPLE[TUPLE 1[E_]]]): BOOLEAN
effective function
{ANY}
Does at least one item satisfy test?
aggregate (action: FUNCTION[TUPLE[TUPLE 2[E_, E_], E_]], initial: E_): E_
effective function
{ANY}
Aggregate all the elements starting from the initial value.
out_in_tagged_out_memory
effective procedure
{ANY}
Append terse printable representation of current object in tagged_out_memory.
generation: INTEGER_32
writable attribute
{ANY}
next_generation
effective procedure
{}
do_all (action: ROUTINE[TUPLE[TUPLE 1[E_]]])
frozen
effective procedure
{ANY}
Apply action to every item of Current.
_inline_agent1 (a: ROUTINE[TUPLE[TUPLE 1[E_]]], e: E_)
frozen
effective procedure
{}
valid_index (i: INTEGER_32): BOOLEAN
effective function
{ANY}
True when i is valid (i.e., inside actual bounds).
wrapper_or_void (a_pointer: POINTER): ITEM_
effective function
A wrapper for a_pointer or Void if a_pointer default_pointer (NULL in C).
null_or (a_wrapper: WRAPPER): POINTER
effective function
{}
The handle of a_wrapper, or the default_pointer if a_wrapper is Void
null_or_string (a_string: ABSTRACT_STRING): POINTER
effective function
{}
A pointer to a memory area containing the content of a_string or default_pointer if a_string is Void.
null_or_array (a_collection: WRAPPER_COLLECTION[WRAPPER]): POINTER
effective function
{}
A pointer to the contenct of a_collection or NULL (default_pointer) if a_collection is Void
collection_to_c_array (a_collection: COLLECTION[WRAPPER]): FAST_ARRAY[POINTER]
effective function
{}
An array containing the pointers to the objects wrapped by a_collection wrappers.
pointer_to_unwrapped_deferred_object: STRING
is "A C function returned a pointer to an unwrapped object which is wrapped by a deferred class. It is not possible to create a correct wrapper."
constant attribute
{}
retrieved_object_mismatch: STRING
is "Retrieved_object_mismatch: the Eiffel wrapper associated with a pointer is not an actual wrapper for the object referred by that pointer "
constant attribute
{}
copying_an_uncopyable: STRING
is "Trying to copy an uncopyable wrapper: such objects are usually shortly lived"
constant attribute
{}
Check_instruction: INTEGER_32
is 1
constant attribute
{ANY}
Exception code for violated check.
Class_invariant: INTEGER_32
is 2
constant attribute
{ANY}
Exception code for violated class invariant.
Developer_exception: INTEGER_32
is 3
constant attribute
{ANY}
Exception code for developer exception.
Incorrect_inspect_value: INTEGER_32
is 4
constant attribute
{ANY}
Exception code for inspect statement.
Loop_invariant: INTEGER_32
is 5
constant attribute
{ANY}
Exception code for violated loop invariant
Loop_variant: INTEGER_32
is 6
constant attribute
{ANY}
Exception code for non-decreased loop variant
No_more_memory: INTEGER_32
is 7
constant attribute
{ANY}
Exception code for failed memory allocation
Postcondition: INTEGER_32
is 8
constant attribute
{ANY}
Exception code for violated postcondition.
Precondition: INTEGER_32
is 9
constant attribute
{ANY}
Exception code for violated precondition.
Routine_failure: INTEGER_32
is 10
constant attribute
{ANY}
Exception code for failed routine.
Os_signal: INTEGER_32
is 11
constant attribute
{ANY}
Exception code for a signal received from the OS.
Void_attached_to_expanded: INTEGER_32
is 12
constant attribute
{ANY}
Exception code for attachment of Void value to expanded entity.
Void_call_target: INTEGER_32
is 13
constant attribute
{ANY}
Exception code for feature applied to Void reference
System_level_type_error: INTEGER_32
is 14
constant attribute
{ANY}
Exception code for the system-level type error (this kind of error mostly arise with covariant redefinition).
exception_name: STRING
effective function
{ANY}
name_of_exception (a_exception: INTEGER_32): STRING
effective function
{ANY}
developer_exception: EXCEPTION
effective function
{ANY}
The last developer-thrown exception.
developer_exception_name: STRING
effective function
{ANY}
Name of last developer-raised exception.
is_developer_exception: BOOLEAN
effective function
{ANY}
Is the last exception originally due to a developer exception?
is_developer_named_exception: BOOLEAN
effective function
{ANY}
Is the last exception originally due to a developer exception?
is_developer_exception_of_name (name: STRING): BOOLEAN
effective function
{ANY}
Is the last exception originally due to a developer exception of name name?
assertion_violation: BOOLEAN
effective function
{ANY}
Is last exception originally due to a violated assertion or non-decreasing variant?
exception: INTEGER_32
{ANY}
Code of last exception that occurred.
is_signal: BOOLEAN
effective function
{ANY}
Is last exception originally due to an external event (operating system signal) ?
die (code: INTEGER_32)
effective procedure
{ANY}
Terminate execution with exit status code, without triggering an exception.
raise (name: STRING)
effective procedure
{ANY}
Raise a developer exception of name name.
throw (a_exception: EXCEPTION)
effective procedure
{ANY}
signal_number: INTEGER_32
{ANY}
Signal Number received from OS.
named_exception: NAMED_EXCEPTION
once function
{}
developer_exception_memory: REFERENCE[EXCEPTION]
once function
{}
raise_exception (code: INTEGER_32)
{}