GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
ov-java.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2007-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_ov_java_h)
27#define octave_ov_java_h 1
28
29#include "octave-config.h"
30
31#include "ov.h"
32#include "ovl.h"
33
35
36class type_info;
37
38OCTAVE_END_NAMESPACE(octave)
39
40typedef void *voidptr;
41
42class OCTINTERP_API octave_java : public octave_base_value
43{
44public:
45
46 octave_java ();
47
48 octave_java (const voidptr& obj, void *cls = nullptr);
49
51 : octave_base_value (jobj), m_java_object (nullptr), m_java_class (nullptr)
52 {
53 init (jobj.m_java_object, jobj.m_java_class);
54 }
55
57
58 void * to_java () const { return m_java_object; }
59 void * to_class () const { return m_java_class; }
60
61 std::string java_class_name () const { return m_java_classname; }
62
63 octave_base_value * clone () const { return new octave_java (*this); }
64 octave_base_value * empty_clone () const { return new octave_java (); }
65
66 bool is_instance_of (const std::string&) const;
67
68 bool is_defined () const { return true; }
69
70 bool is_constant () const { return true; }
71
72 bool isstruct () const { return false; }
73
74 bool isjava () const { return true; }
75
76 string_vector map_keys () const;
77
78 dim_vector dims () const;
79
80 void print (std::ostream& os, bool pr_as_read_syntax = false);
81
82 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
83
84 bool save_ascii (std::ostream& os);
85
86 bool load_ascii (std::istream& is);
87
88 bool save_binary (std::ostream& os, bool save_as_floats);
89
90 bool load_binary (std::istream& is, bool swap,
91 octave::mach_info::float_format fmt);
92
93 bool save_hdf5 (octave_hdf5_id loc_id, const char *name,
94 bool save_as_floats);
95
96 bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
97
98 // We don't need to override all three forms of subsref. The using
99 // declaration will avoid warnings about partially-overloaded virtual
100 // functions.
102
104 subsref (const std::string& type,
105 const std::list<octave_value_list>& idx, int nargout);
106
108 subsref (const std::string& type, const std::list<octave_value_list>& idx)
109 {
110 octave_value_list retval = subsref (type, idx, 1);
111 return (retval.length () > 0 ? retval(0) : octave_value ());
112 }
113
114 octave_value subsasgn (const std::string& type,
115 const std::list<octave_value_list>& idx,
116 const octave_value& rhs);
117
118 octave_value convert_to_str_internal (bool pad, bool force, char type) const;
119
120 bool is_java_string () const;
121
122 octave_value do_javaMethod (void *jni_env, const std::string& name,
123 const octave_value_list& args);
124
126 do_javaMethod (const std::string& name, const octave_value_list& args);
127
128 static octave_value
129 do_javaMethod (void *jni_env, const std::string& class_name,
130 const std::string& name, const octave_value_list& args);
131
132 static octave_value
133 do_javaMethod (const std::string& class_name, const std::string& name,
134 const octave_value_list& args);
135
136 static octave_value
137 do_javaObject (void *jni_env, const std::string& name,
138 const octave_value_list& args);
139
140 static octave_value
141 do_javaObject (const std::string& name, const octave_value_list& args);
142
143 octave_value do_java_get (void *jni_env, const std::string& name);
144
145 octave_value do_java_get (const std::string& name);
146
147 static octave_value
148 do_java_get (void *jni_env, const std::string& class_name,
149 const std::string& name);
150
151 static octave_value
152 do_java_get (const std::string& class_name, const std::string& name);
153
154 octave_value do_java_set (void *jni_env, const std::string& name,
155 const octave_value& val);
156
157 octave_value do_java_set (const std::string& name, const octave_value& val);
158
159 static octave_value
160 do_java_set (void *jni_env, const std::string& class_name,
161 const std::string& name, const octave_value& val);
162
163 static octave_value
164 do_java_set (const std::string& class_name, const std::string& name,
165 const octave_value& val);
166
167private:
168
169 void init (void *jobj, void *jcls);
170
171 void release ();
172
173private:
174
175 void *m_java_object;
176
177 void *m_java_class;
178
179 std::string m_java_classname;
180
181public:
182
183 int type_id () const { return s_t_id; }
184 std::string type_name () const { return s_t_name; }
185 std::string class_name () const { return m_java_classname; }
186
187 static int static_type_id () { return s_t_id; }
188 static std::string static_type_name () { return s_t_name; }
189 static std::string static_class_name () { return "<unknown>"; }
190 static void register_type (octave::type_info&);
191
192private:
193
194 static int s_t_id;
195 static const std::string s_t_name;
196};
197
198extern OCTINTERP_API bool Vjava_matrix_autoconversion;
199
200extern OCTINTERP_API bool Vjava_unsigned_autoconversion;
201
202extern OCTINTERP_API bool Vdebug_java;
203
204#endif
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition ov-base.cc:245
void * to_java() const
Definition ov-java.h:58
std::string class_name() const
Definition ov-java.h:185
octave_base_value * clone() const
Definition ov-java.h:63
~octave_java()
Definition ov-java.h:56
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition ov-java.h:108
static std::string static_class_name()
Definition ov-java.h:189
octave_base_value * empty_clone() const
Definition ov-java.h:64
int type_id() const
Definition ov-java.h:183
bool is_defined() const
Definition ov-java.h:68
bool isjava() const
Definition ov-java.h:74
static int static_type_id()
Definition ov-java.h:187
static std::string static_type_name()
Definition ov-java.h:188
bool isstruct() const
Definition ov-java.h:72
std::string type_name() const
Definition ov-java.h:184
octave_java(const octave_java &jobj)
Definition ov-java.h:50
void * to_class() const
Definition ov-java.h:59
std::string java_class_name() const
Definition ov-java.h:61
bool is_constant() const
Definition ov-java.h:70
octave_idx_type length() const
Definition ovl.h:111
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::string release()
Definition defaults.cc:151
int64_t octave_hdf5_id
bool Vjava_unsigned_autoconversion
Definition ov-java.cc:223
void * voidptr
Definition ov-java.h:40
bool Vjava_matrix_autoconversion
Definition ov-java.cc:222
bool Vdebug_java
Definition ov-java.cc:224
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)