/[eiffelstudio]/trunk/Src/library/Eiffel2Java/java_int_array.e
ViewVC logotype

Contents of /trunk/Src/library/Eiffel2Java/java_int_array.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34643 - (show annotations)
Mon Oct 21 01:50:49 2002 UTC (17 years, 4 months ago) by manus
File size: 2087 byte(s)
Rewrote of Eiffel2Java:
- it is now compatible with .NET
- it does not use any additional C libraries
- it adds a lot more contracts
- it works with SJDK 1.4 only

1 indexing
2 description: "Access to Java array of 'int'"
3 date: "$Date$"
4 revision: "$Revision$"
5
6 class
7 JAVA_INT_ARRAY
8
9 inherit
10 JAVA_ARRAY
11
12 create
13 make,
14 make_from_pointer
15
16 feature -- Initialization
17
18 make (size: INTEGER) is
19 -- Create a new Java array and an Eiffel accessor object
20 -- Note: Java arrays are indexed from zero
21 require
22 size_ok: size > 0
23 do
24 jarray := jni.new_int_array (size)
25 create jvalue.make
26 ensure
27 array_ok: jarray /= default_pointer
28 end
29
30 feature -- Access
31
32 item (index: INTEGER): INTEGER is
33 -- Item at `index'.
34 require
35 valid_index: valid_index (index)
36 local
37 l_array_ptr: POINTER
38 do
39 l_array_ptr := jni.get_int_array_elements (jarray, default_pointer)
40 jvalue.make_by_pointer (l_array_ptr + index * sizeof_jint)
41 Result := jvalue.int_value
42 jni.release_int_array_elements (jarray, l_array_ptr, 0)
43 end
44
45 feature -- Element change
46
47 put (an_item: INTEGER; index: INTEGER) is
48 -- Put `an_item' at `index'.
49 require
50 valid_index: valid_index (index)
51 local
52 l_array_ptr: POINTER
53 do
54 l_array_ptr := jni.get_int_array_elements (jarray, default_pointer)
55 jvalue.make_by_pointer (l_array_ptr + index * sizeof_jint)
56 jvalue.set_int_value (an_item)
57 jni.release_int_array_elements (jarray, l_array_ptr, 0)
58 ensure
59 inserted: item (index) = an_item
60 end
61
62 end
63
64
65 --|----------------------------------------------------------------
66 --| Eiffel2Java: library of reusable components for ISE Eiffel.
67 --| Copyright (C) 1986-2001 Interactive Software Engineering Inc.
68 --| All rights reserved. Duplication and distribution prohibited.
69 --| May be used only with ISE Eiffel, under terms of user license.
70 --| Contact ISE for any other use.
71 --|
72 --| Interactive Software Engineering Inc.
73 --| ISE Building
74 --| 360 Storke Road, Goleta, CA 93117 USA
75 --| Telephone 805-685-1006, Fax 805-685-6869
76 --| Electronic mail <info@eiffel.com>
77 --| Customer support: http://support.eiffel.com>
78 --| For latest info see award-winning pages: http://www.eiffel.com
79 --|----------------------------------------------------------------
80

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23