Author:halw

Date:2008-12-01T22:45:08.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@112 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2008-12-01 22:45:08 +00:00
parent 7312cec21e
commit bba0936e07
11 changed files with 282 additions and 252 deletions

View File

@@ -43,58 +43,59 @@ Value of `my_integer' after call to `my_method' is 2
===Code description===
<code>(Eiffel Code)
class
EIFFEL_TO_JAVA
inherit
SHARED_JNI_ENVIRONMENT
class
EIFFEL_TO_JAVA
inherit
SHARED_JNI_ENVIRONMENT
create
make
make
feature -- Creation
feature -- Creation
make is
local
class_test: JAVA_CLASS
instance_of_class_test: JAVA_OBJECT
fid: POINTER
value: INTEGER
j_args: JAVA_ARGS
do
--| Creation of the Java object
class_test := jni.find_class ("test")
create instance_of_class_test.create_instance (class_test, "()V", Void)
make
local
class_test: JAVA_CLASS
instance_of_class_test: JAVA_OBJECT
fid: POINTER
value: INTEGER
j_args: JAVA_ARGS
do
--| Creation of the Java object
class_test := jni.find_class ("test")
create instance_of_class_test.create_instance (class_test, "()V", Void)
--| Access to a public attribute
fid := instance_of_class_test.field_id ("my_integer", "I")
--| Access to a public attribute
fid := instance_of_class_test.field_id ("my_integer", "I")
-- 'fid' contains the id of the field 'my_integer'
-- 'value' contains the value of the field referenced
-- by 'fid'
-- 'fid' contains the id of the field 'my_integer'
-- 'value' contains the value of the field referenced
-- by 'fid'
value := instance_of_class_test.integer_attribute (fid)
value := instance_of_class_test.integer_attribute (fid)
--| Access to a static attribute using directly the JAVA_CLASS
fid := class_test.field_id ("my_static_integer", "I")
value := class_test.integer_attribute (fid) ...
--| Access to a static attribute using the attribute 'jclass'
fid := instance_of_class_test.jclass.field_id ("my_static_integer", "I")
value := instance_of_class_test.jclass.integer_attribute (fid)
--| Access to the method 'my_method'
-- Get the id of 'my_method'
fid := instance_of_class_test.method_id ("my_method", "(ILjava/lang/String;)V")
--| Access to a static attribute using directly the JAVA_CLASS
fid := class_test.field_id ("my_static_integer", "I")
value := class_test.integer_attribute (fid)
-- Create the set of arguments for 'my_method'
create j_args.make(2)
j_args.push_int (2)
j_args.push_string("String test")
-- Create the set of arguments for 'my_method'
-- Call to the void method referenced by 'fid'
instance_of_class_test.void_method (fid, j_args)
end -- make
--| Access to a static attribute using the attribute 'jclass'
fid := instance_of_class_test.jclass.field_id ("my_static_integer", "I")
value := instance_of_class_test.jclass.integer_attribute (fid)
--| Access to the method 'my_method'
-- Get the id of 'my_method'
fid := instance_of_class_test.method_id ("my_method", "(ILjava/lang/String;)V")
-- Create the set of arguments for 'my_method'
create j_args.make(2)
j_args.push_int (2)
j_args.push_string("String test")
-- Create the set of arguments for 'my_method'
-- Call to the void method referenced by 'fid'
instance_of_class_test.void_method (fid, j_args)
end -- make
end -- class EIFFEL_TO_JAVA</code>