01: // Copyright (c) Corporation for National Research Initiatives
02: package org.python.core;
03:
04: import java.util.Vector;
05:
06: public class PyCompoundCallable extends PyObject {
07: private Vector callables;
08: private PySystemState systemState;
09:
10: public PyCompoundCallable() {
11: callables = new Vector();
12: systemState = Py.getSystemState();
13: }
14:
15: public void append(PyObject callable) {
16: callables.addElement(callable);
17: }
18:
19: public void clear() {
20: callables.removeAllElements();
21: }
22:
23: public PyObject __call__(PyObject[] args, String[] keywords) {
24: // Set the system state to handle callbacks from java threads
25: Py.setSystemState(systemState);
26: int n = callables.size();
27: //System.out.println("callable: "+n);
28: for (int i = 0; i < n; i++) {
29: ((PyObject) callables.elementAt(i))
30: .__call__(args, keywords);
31: }
32: return Py.None;
33: }
34:
35: public String toString() {
36: return "<CompoundCallable with " + callables.size()
37: + " callables>";
38: }
39: }
|