Refine search
public Object invoke(Object... args) throws Exception { PyObject[] pyArgs = new PyObject[args.length]; for (int i = 0; i < args.length; i++) pyArgs[i] = Py.java2py(args[i]); PyObject pyResult = fn.__call__(pyArgs); if (pyResult == null) return null; // todo: number conversions should be handled higher up in the code, and not at the Jython level. if (pyResult instanceof PyLong || pyResult instanceof PyInteger) return pyResult.__tojava__(Long.class); Object result = pyResult.__tojava__(Object.class); if (result == Py.NoConversion) throw new RuntimeException("Cannot convert Python object " + pyResult + " to java."); return result; }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
@Override public synchronized Object set(int index, Object element) { return list.set(index, Py.java2py(element)).__tojava__(Object.class); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
@Override public PyObject __call__(PyObject memo) { Set<Object> newSet = new HashSet<>(); for (Object obj : asSet()) { PyObject pyobj = Py.java2py(obj); PyObject newobj = pyobj.invoke("__deepcopy__", memo); newSet.add(newobj.__tojava__(Object.class)); } return makePySet(newSet); } };
@Override public PyObject __call__(PyObject name) { try { return objectGetattribute.__call__(self, name); } catch (PyException pye) { if (!pye.match(Py.AttributeError)) { throw pye; } } CustomizableMapHolder inst = Py.tojava(self, CustomizableMapHolder.class); return Py.java2py(inst.held.get(Py.tojava(name, String.class))); } };
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
@ExposedMethod(defaults = "Py.None") final PyObject scope_setdefault(PyObject keyObj, PyObject failObj) { PyObject result; String key = keyObj.asString(); int scope = context.getAttributesScope(key); if (scope == -1) { scope = ScriptContext.ENGINE_SCOPE; context.setAttribute(key, failObj instanceof PyType ? failObj : failObj.__tojava__(Object.class), scope); result = failObj; } else { result = Py.java2py(context.getAttribute(key, scope)); } return result; }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }
public Object __tojava__(Class c) { // If we are not being asked by the "default" conversion to java, then // we can provide this as the result, as long as it is a instance of the // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: PyType self_type=getType(); PyObject impl=self_type.lookup("__tojava__"); if (impl!=null) { PyObject delegate=impl.__get__(this,self_type).__call__(Py.java2py(c)); if (delegate!=this) return delegate.__tojava__(Object.class); } return super.__tojava__(c); }