/** * Return a Dialect instance created or updated from keyword arguments. */ private static PyDialect dialectFromKwargs(PyObject dialect, PyObject[] args, String[] keywords) { PyObject[] dialectArgs; int argc = args.length - keywords.length; // was a dialect keyword specified? boolean dialectKeyword = false; for (String keyword : keywords) { if (keyword.equals("dialect")) { dialectKeyword = true; } } if (dialect == null || dialectKeyword) { // dialect wasn't passed as a positional arg dialectArgs = new PyObject[keywords.length]; System.arraycopy(args, argc, dialectArgs, 0, keywords.length); } else { // have dialect -- pass it to dialect_new as a positional arg dialectArgs = new PyObject[1 + keywords.length]; dialectArgs[0] = dialect; System.arraycopy(args, argc, dialectArgs, 1, keywords.length); } return (PyDialect)PyDialect.TYPE.__call__(dialectArgs, keywords); }
/** * Return a copy of this property with the optional addition of a get/set/del. Helper * method for the getter/setter/deleter methods. */ private PyObject propertyCopy(PyObject get, PyObject set, PyObject del) { if (get == null) { get = fget != null ? fget : Py.None; } if (set == null) { set = fset != null ? fset : Py.None; } if (del == null) { del = fdel != null ? fdel : Py.None; } PyObject doc; if (docFromGetter) { // make _init use __doc__ from getter doc = Py.None; } else { doc = this.doc != null ? this.doc : Py.None; } return getType().__call__(get, set, del, doc); }
protected PyObject makePySet(Set newSet) { PyObject newPySet = self.getType().__call__(); @SuppressWarnings("unchecked") Set<Object> jSet = ((Set<Object>) newPySet.getJavaProxy()); jSet.addAll(newSet); return newPySet; }
public final PyObject get(Memory mem, long offset) { PyObject result = type.__call__(op.get(mem, offset)); // // Point the CData to the backing memory so all value gets/sets // update the same memory this pointer points to // if (result instanceof ScalarCData) { ((ScalarCData) result).setReferenceMemory(mem); } return result; } }
@ExposedClassMethod(defaults = "Py.None", doc = BuiltinDocs.dict_fromkeys_doc) static PyObject dict_fromkeys(PyType type, PyObject keys, PyObject value) { PyObject d = type.__call__(); for (PyObject o : keys.asIterable()) { d.__setitem__(o, value); } return d; }
@ExposedMethod final PyObject deque___copy__() { PyDeque pd = (PyDeque)this.getType().__call__(); pd.deque_extend(this); return pd; }
@ExposedClassMethod(defaults = "Py.None", doc = BuiltinDocs.dict_fromkeys_doc) static PyObject stringmap_fromkeys(PyType type, PyObject keys, PyObject value) { PyObject d = type.__call__(); for (PyObject o : keys.asIterable()) { d.__setitem__(o, value); } return d; }
public PyObject __call__(PyObject args[],String keywords[]) { PyType self_type=getType(); PyObject impl=self_type.lookup("__call__"); if (impl!=null) { return impl.__get__(this,self_type).__call__(args,keywords); } return super.__call__(args,keywords); }
@Override public PyObject __call__(PyObject arg) { long ticks; switch (index) { case 4: ticks = ((Number) arg.__tojava__(Number.class)).longValue(); return zxJDBC.datefactory.DateFromTicks(ticks); case 5: ticks = ((Number) arg.__tojava__(Number.class)).longValue(); return zxJDBC.datefactory.TimeFromTicks(ticks); case 6: ticks = ((Number) arg.__tojava__(Number.class)).longValue(); return zxJDBC.datefactory.TimestampFromTicks(ticks); case 7: if (arg instanceof PyString) { arg = PyArray.TYPE.__call__(Py.newString("b"), arg); } return arg; default : throw info.unexpectedCall(1, false); } }
/** * Create a new set of type from iterable. * * @param type a set type * @param iterable an iterable or null * @return a new set */ protected static BaseSet makeNewSet(PyType type, PyObject iterable) { BaseSet so; if (type == PySet.TYPE) { so = new PySet(iterable); } else if (type == PyFrozenSet.TYPE) { so = new PyFrozenSet(iterable); } else if (Py.isSubClass(type, PySet.TYPE)) { so = (BaseSet)(type.__call__(iterable == null ? Py.EmptyTuple : iterable)); } else { so = new PyFrozenSetDerived(type, iterable); } return so; }
+ "': maybe you need to set the '" + PYTHON_HOME_PARAM + "' parameter?", ix); PyObject pyServlet = ((PyType)interp.get(MODJY_PYTHON_CLASSNAME)).__call__(); Object temp = pyServlet.__tojava__(HttpServlet.class); if (temp == Py.NoConversion)
@ExposedMethod(defaults = "null", doc = BuiltinDocs.super___get___doc) final PyObject super___get__(PyObject obj, PyObject type) { if (obj == null || obj == Py.None || this.obj != null) { return this; } if (getType() != TYPE) { // If an instance of a (strict) subclass of super, call its type return getType().__call__(type, obj); } else { // Inline the common case PyType objType = supercheck(this.superType, obj); PySuper newsuper = new PySuper(); newsuper.superType = this.superType; newsuper.obj = obj; newsuper.objType = objType; return newsuper; } }
pargs = Py.javas2pys(args); instance = pyc.__call__(pargs); JyAttribute.setAttr(instance, JyAttribute.JAVA_PROXY_ATTR, proxy); proxy._setPyInstance(instance);
@Override public PyObject __call__(PyObject args[], String kwds[]) { ArgParser ap = new ArgParser("file", args, kwds, new String[] {"name", "mode", "buffering"}, 1); PyObject obj = ap.getPyObject(0); if (obj.getJavaProxy() != null) { int bufsize = ap.getInt(2, -1); Object javaProxy = obj.getJavaProxy(); if (javaProxy instanceof InputStream) { Py.warning(Py.DeprecationWarning, warning); return new PyFile((InputStream) javaProxy, bufsize); } else if (javaProxy instanceof OutputStream) { Py.warning(Py.DeprecationWarning, warning); return new PyFile((OutputStream) javaProxy, bufsize); } } return PyFile.TYPE.__call__(args, kwds); } }
public static PyObject classobj___new__(PyObject name, PyObject bases, PyObject dict) { if (!name.getType().isSubType(PyString.TYPE)) { throw Py.TypeError("PyClass_New: name must be a string"); } if (!(dict instanceof PyStringMap || dict instanceof PyDictionary)) { throw Py.TypeError("PyClass_New: dict must be a dictionary"); } PyType.ensureDoc(dict); PyType.ensureModule(dict); if (!(bases instanceof PyTuple)) { throw Py.TypeError("PyClass_New: bases must be a tuple"); } PyTuple basesTuple = (PyTuple)bases; for (PyObject base : basesTuple.getArray()) { if (!(base instanceof PyClass)) { if (base.getType().isCallable()) { return base.getType().__call__(name, bases, dict); } else { throw Py.TypeError("PyClass_New: base must be a class"); } } } PyClass klass = new PyClass(); klass.__name__ = name.toString(); klass.__bases__ = basesTuple; klass.__dict__ = dict; klass.cacheDescriptors(); return klass; }