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

Contents of /trunk/Src/experimental/library/Eiffel2Java/java_double_array.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 81105 - (show annotations)
Fri Oct 9 17:02:01 2009 UTC (10 years, 4 months ago) by manus
File size: 1813 byte(s)
Added explicit conversion from REAL_64 to REAL_32 since there are no more implicit one.

1 note
2 description: "Access to Java array of doubles"
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 class
9 JAVA_DOUBLE_ARRAY
10
11 inherit
12 JAVA_ARRAY
13
14 create
15 make,
16 make_from_pointer
17
18 feature -- Initialization
19
20 make (size: INTEGER)
21 -- Create a new Java array and an Eiffel accessor object
22 -- Note: Java arrays are indexed from zero
23 require
24 size_ok: size > 0
25 do
26 jarray := jni.new_double_array (size)
27 create jvalue.make
28 ensure
29 array_ok: jarray /= default_pointer
30 end
31
32 feature -- Access
33
34 item (index: INTEGER): REAL
35 -- Item at `index'.
36 require
37 valid_index: valid_index (index)
38 local
39 l_array_ptr: POINTER
40 do
41 l_array_ptr := jni.get_double_array_elements (jarray, default_pointer)
42 jvalue.make_by_pointer (l_array_ptr + index * sizeof_jdouble)
43 Result := jvalue.double_value.truncated_to_real
44 jni.release_double_array_elements (jarray, l_array_ptr, 0)
45 end
46
47 feature -- Element change
48
49 put (an_item: DOUBLE; index: INTEGER)
50 -- Put `an_item' at `index'.
51 require
52 valid_index: valid_index (index)
53 local
54 l_array_ptr: POINTER
55 do
56 l_array_ptr := jni.get_double_array_elements (jarray, default_pointer)
57 jvalue.make_by_pointer (l_array_ptr + index * sizeof_jdouble)
58 jvalue.set_double_value (an_item)
59 jni.release_double_array_elements (jarray, l_array_ptr, 0)
60 ensure
61 inserted: item (index) = an_item
62 end
63
64 note
65 copyright: "Copyright (c) 1984-2009, Eiffel Software and others"
66 license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
67 source: "[
68 Eiffel Software
69 5949 Hollister Ave., Goleta, CA 93117 USA
70 Telephone 805-685-1006, Fax 805-685-6869
71 Website http://www.eiffel.com
72 Customer support http://support.eiffel.com
73 ]"
74
75
76
77
78 end
79

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23