Mercurial > hg > octave-nkf
annotate scripts/java/org/octave/Octave.java @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | d63878346099 |
children |
rev | line source |
---|---|
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
1 /* |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
2 |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15753
diff
changeset
|
3 Copyright (C) 2007, 2013 Michael Goffioul |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
4 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
5 This file is part of Octave. |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
6 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or (at |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
10 your option) any later version. |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
11 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
15 General Public License for more details. |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
16 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
20 |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 package org.octave; |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 import java.util.*; |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 public class Octave |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 { |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 private static Object notifyObject = null; |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 private static Object[] args = null; |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
31 private static LinkedList invokeList = new LinkedList (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
32 private static LinkedList waitList = new LinkedList (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 public native static boolean call (String name, Object[] argin, Object[] argout); |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
35 public native static void doInvoke (int ID, Object[] args); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
36 public native static void doEvalString (String cmd); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
37 public native static boolean needThreadedInvokation (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
39 public static void checkPendingAction () |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
40 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
41 if (notifyObject != null) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
42 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
43 synchronized (notifyObject) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
44 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
45 if (notifyObject instanceof OctaveReference) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
46 doInvoke (((OctaveReference)notifyObject).getID (), args); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
47 else if (notifyObject instanceof String) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
48 doEvalString ((String)notifyObject); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
49 notifyObject.notifyAll (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
50 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
51 notifyObject = null; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
52 args = null; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
53 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
55 Object obj; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
56 Object[] objArgs; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
58 while (true) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
59 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
60 obj = null; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
61 objArgs = null; |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
63 synchronized (invokeList) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
64 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
65 if (invokeList.size () > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
66 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
67 obj = invokeList.remove (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
68 if (obj instanceof OctaveReference) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
69 objArgs = (Object[])invokeList.remove (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
70 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
71 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
73 if (obj != null) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
74 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
75 if (obj instanceof Runnable) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
76 ((Runnable)obj).run (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
77 else if (obj instanceof OctaveReference) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
78 doInvoke (((OctaveReference)obj).getID (), objArgs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
79 else if (obj instanceof String) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
80 doEvalString ((String)obj); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
81 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
82 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
83 break; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
84 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
85 /* |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
86 synchronized (invokeList) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
87 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
88 while (invokeList.size () > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
89 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
90 Object obj = invokeList.remove (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
91 if (obj instanceof Runnable) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
92 ((Runnable)obj).run (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
93 if (obj instanceof OctaveReference) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
94 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
95 Object[] objArgs = (Object[])invokeList.remove (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
96 doInvoke (((OctaveReference)obj).getID (), objArgs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
97 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
98 else if (obj instanceof String) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
99 doEvalString ((String)obj); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
100 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
101 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
102 */ |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
103 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
105 private static void checkWaitState () |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
106 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
107 if (waitList.size () > 0) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
108 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
109 Object wObj = waitList.getFirst (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
110 synchronized (wObj) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
111 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
112 wObj.notifyAll (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
113 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
114 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
115 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
117 public static void invokeAndWait (OctaveReference ref, Object[] invokeArgs) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
118 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
119 if (needThreadedInvokation ()) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
120 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
121 synchronized (ref) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
122 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
123 notifyObject = ref; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
124 args = invokeArgs; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
125 try { checkWaitState (); ref.wait (); } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
126 catch (InterruptedException e) {} |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
127 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
128 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
129 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
130 doInvoke (ref.getID (), invokeArgs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
131 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
132 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
133 public static void evalAndWait (String cmd) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
134 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
135 if (needThreadedInvokation ()) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
136 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
137 synchronized (cmd) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
138 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
139 notifyObject = cmd; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
140 args = null; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
141 try { checkWaitState (); cmd.wait (); } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
142 catch (InterruptedException e) {} |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
143 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
144 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
145 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
146 doEvalString (cmd); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
147 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
148 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
149 public static void invokeLater (Runnable r) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
150 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
151 if (needThreadedInvokation ()) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
152 synchronized (invokeList) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
154 invokeList.add (r); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
155 checkWaitState (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
157 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
158 r.run (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
159 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
161 public static void invokeLater (OctaveReference ref, Object[] invokeArgs) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
162 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
163 if (needThreadedInvokation ()) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
164 synchronized (invokeList) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
166 invokeList.add (ref); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
167 invokeList.add (invokeArgs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
168 checkWaitState (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
170 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
171 doInvoke (ref.getID (), invokeArgs); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
172 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
174 public static void evalLater (String cmd) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
175 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
176 if (needThreadedInvokation ()) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
177 synchronized (invokeList) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
178 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
179 invokeList.add (cmd); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
180 checkWaitState (); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
181 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
182 else |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
183 doEvalString (cmd); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
184 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
186 public static void waitFor (Object wObj) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
187 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
188 waitList.add (0, wObj); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
189 synchronized (wObj) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
190 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
191 while (waitList.size () > 0 && waitList.getFirst () == wObj) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
193 try { wObj.wait (); } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
194 catch (InterruptedException e) {} |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
195 checkPendingAction (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
197 } |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
198 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
200 public static void endWaitFor (Object obj) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
201 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
202 boolean isCurrentWaitObject = (waitList.size () > 0 && waitList.getFirst () == obj); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
203 |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
204 waitList.remove (obj); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
205 if (needThreadedInvokation () && isCurrentWaitObject) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
206 synchronized (obj) |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 { |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
208 obj.notifyAll (); |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 } |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
210 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 |
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 public static Object do_test (String name, Object arg0) throws Exception |
15753
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
213 { |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
214 Object[] argin = new Object[] { arg0 }; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
215 Object[] argout = new Object[1]; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
216 if (call (name, argin, argout)) |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
217 return argout[0]; |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
218 throw new Exception ("octave call failed"); |
6e39fe7992d9
style fixes and copyright update for java files
John W. Eaton <jwe@octave.org>
parents:
15752
diff
changeset
|
219 } |
15625
acf0addfc610
include Octave Forge java package in core Octave
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 } |