All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.qt.core.QMetaMethod Maven / Gradle / Ivy

There is a newer version: 6.3.0
Show newest version
package io.qt.core;


/**
 * 

Meta-data about a member function

*

Java wrapper for Qt class QMetaMethod

*/ public class QMetaMethod extends io.qt.QtObject implements java.lang.Cloneable { static { QtJambi_LibraryUtilities.initialize(); } /** *

Java wrapper for Qt enum QMetaMethod::Access

*/ public enum Access implements io.qt.QtEnumerator { Private(0), Protected(1), Public(2); private Access(int value) { this.value = value; } /** * {@inheritDoc} */ public int value() { return value; } /** * Returns the corresponding enum entry for the given value. * @param value * @return enum entry */ public static Access resolve(int value) { switch (value) { case 0: return Private; case 1: return Protected; case 2: return Public; default: throw new io.qt.QNoSuchEnumValueException(value); } } private final int value; } /** *

Java wrapper for Qt enum QMetaMethod::Attributes

*/ public enum Attributes implements io.qt.QtEnumerator { Compatibility(1), Cloned(2), Scriptable(4); private Attributes(int value) { this.value = value; } /** * {@inheritDoc} */ public int value() { return value; } /** * Returns the corresponding enum entry for the given value. * @param value * @return enum entry */ public static Attributes resolve(int value) { switch (value) { case 1: return Compatibility; case 2: return Cloned; case 4: return Scriptable; default: throw new io.qt.QNoSuchEnumValueException(value); } } private final int value; } /** *

Java wrapper for Qt enum QMetaMethod::MethodType

*/ public enum MethodType implements io.qt.QtEnumerator { Method(0), Signal(1), Slot(2), Constructor(3); private MethodType(int value) { this.value = value; } /** * {@inheritDoc} */ public int value() { return value; } /** * Returns the corresponding enum entry for the given value. * @param value * @return enum entry */ public static MethodType resolve(int value) { switch (value) { case 0: return Method; case 1: return Signal; case 2: return Slot; case 3: return Constructor; default: throw new io.qt.QNoSuchEnumValueException(value); } } private final int value; } /** *

See QMetaMethod::access()const

*/ @io.qt.QtUninvokable public final io.qt.core.QMetaMethod.Access access(){ return io.qt.core.QMetaMethod.Access.resolve(access_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this))); } @io.qt.QtUninvokable private native int access_native_constfct(long __this__nativeId); @io.qt.QtUninvokable public final int attributes(){ return attributes_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int attributes_native_constfct(long __this__nativeId); @io.qt.QtUninvokable public final io.qt.core.QMetaObject enclosingMetaObject(){ return enclosingMetaObject_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QMetaObject enclosingMetaObject_native_constfct(long __this__nativeId); /** *

See QMetaMethod::isConst()const

*/ @io.qt.QtUninvokable public final boolean isConst(){ return isConst_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native boolean isConst_native_constfct(long __this__nativeId); /** *

See QMetaMethod::isValid()const

*/ @io.qt.QtUninvokable public final boolean isValid(){ return isValid_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native boolean isValid_native_constfct(long __this__nativeId); /** *

See QMetaMethod::methodIndex()const

*/ @io.qt.QtUninvokable public final int methodIndex(){ return methodIndex_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int methodIndex_native_constfct(long __this__nativeId); /** *

See QMetaMethod::methodSignature()const

*/ @io.qt.QtUninvokable public final io.qt.core.QByteArray cppMethodSignature(){ return cppMethodSignature_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QByteArray cppMethodSignature_native_constfct(long __this__nativeId); /** *

See QMetaMethod::methodType()const

*/ @io.qt.QtUninvokable public final io.qt.core.QMetaMethod.MethodType methodType(){ return io.qt.core.QMetaMethod.MethodType.resolve(methodType_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this))); } @io.qt.QtUninvokable private native int methodType_native_constfct(long __this__nativeId); /** *

See QMetaMethod::name()const

*/ @io.qt.QtUninvokable public final io.qt.core.QByteArray name(){ return name_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QByteArray name_native_constfct(long __this__nativeId); @io.qt.QtUninvokable private final boolean operator_equal(io.qt.core.QMetaMethod m2){ return operator_equal_native_cref_QMetaMethod(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.checkedNativeId(m2)); } @io.qt.QtUninvokable private native boolean operator_equal_native_cref_QMetaMethod(long __this__nativeId, long m2); /** *

See QMetaMethod::parameterCount()const

*/ @io.qt.QtUninvokable public final int parameterCount(){ return parameterCount_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int parameterCount_native_constfct(long __this__nativeId); /** *

See QMetaMethod::parameterMetaType(int)const

*/ @io.qt.QtUninvokable public final io.qt.core.QMetaType parameterMetaType(int index){ return parameterMetaType_native_int_constfct(QtJambi_LibraryUtilities.internal.nativeId(this), index); } @io.qt.QtUninvokable private native io.qt.core.QMetaType parameterMetaType_native_int_constfct(long __this__nativeId, int index); /** *

See QMetaMethod::parameterNames()const

*/ @io.qt.QtUninvokable public final io.qt.core.QList parameterNames(){ return parameterNames_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QList parameterNames_native_constfct(long __this__nativeId); /** *

See QMetaMethod::parameterType(int)const

*/ @io.qt.QtUninvokable public final int parameterType(int index){ return parameterType_native_int_constfct(QtJambi_LibraryUtilities.internal.nativeId(this), index); } @io.qt.QtUninvokable private native int parameterType_native_int_constfct(long __this__nativeId, int index); /** *

See QMetaMethod::parameterTypeName(int)const

*/ @io.qt.QtUninvokable public final io.qt.core.QByteArray parameterTypeName(int index){ return parameterTypeName_native_int_constfct(QtJambi_LibraryUtilities.internal.nativeId(this), index); } @io.qt.QtUninvokable private native io.qt.core.QByteArray parameterTypeName_native_int_constfct(long __this__nativeId, int index); /** *

See QMetaMethod::parameterTypes()const

*/ @io.qt.QtUninvokable public final io.qt.core.QList parameterTypes(){ return parameterTypes_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QList parameterTypes_native_constfct(long __this__nativeId); /** *

See QMetaMethod::relativeMethodIndex()const

*/ @io.qt.QtUninvokable public final int relativeMethodIndex(){ return relativeMethodIndex_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int relativeMethodIndex_native_constfct(long __this__nativeId); /** *

See QMetaMethod::returnMetaType()const

*/ @io.qt.QtUninvokable public final io.qt.core.QMetaType returnMetaType(){ return returnMetaType_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QMetaType returnMetaType_native_constfct(long __this__nativeId); /** *

See QMetaMethod::returnType()const

*/ @io.qt.QtUninvokable public final int returnType(){ return returnType_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int returnType_native_constfct(long __this__nativeId); /** *

See QMetaMethod::revision()const

*/ @io.qt.QtUninvokable public final int revision(){ return revision_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int revision_native_constfct(long __this__nativeId); /** *

See QMetaMethod::tag()const

*/ @io.qt.QtUninvokable public final java.lang.String tag(){ return tag_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native java.lang.String tag_native_constfct(long __this__nativeId); /** *

See QMetaMethod::typeName()const

*/ @io.qt.QtUninvokable public final java.lang.String typeName(){ return typeName_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native java.lang.String typeName_native_constfct(long __this__nativeId); /** * Constructor for internal use only. * @param p expected to be null. */ @io.qt.NativeAccess protected QMetaMethod(QPrivateConstructor p) { super(p); } @Override @io.qt.QtUninvokable public boolean equals(Object other) { if (other instanceof io.qt.core.QMetaMethod) { return operator_equal((io.qt.core.QMetaMethod) other); } return false; } @io.qt.QtUninvokable @Override public int hashCode() { return hashCode_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native static int hashCode_native(long __this_nativeId); private Class returnClassType; private java.util.List> parameterClassTypes; /** *

See QMetaMethod::parameterTypes() const

*/ @io.qt.QtUninvokable public final java.util.List> parameterClassTypes() { if(parameterClassTypes==null) { parameterClassTypes = java.util.Collections.unmodifiableList(parameterClassTypes_native()); } return parameterClassTypes; } @io.qt.QtUninvokable private native final java.util.List> parameterClassTypes_native(); /** *

See QMetaMethod::parameterType(int index) const

*/ @io.qt.QtUninvokable public final Class parameterClassType(int index) { return parameterClassTypes().get(index); } /** *

See QMetaMethod::returnType() const

*/ @io.qt.QtUninvokable public final Class returnClassType(){ if(returnClassType==null) returnClassType = returnClassType_native(); return returnClassType; } @io.qt.QtUninvokable private native final Class returnClassType_native(); /** *

See QMetaMethod::methodSignature() const

*/ @io.qt.QtUninvokable public final String methodSignature() { StringBuilder args = new StringBuilder(); java.util.List> parameterClassTypes = parameterClassTypes(); for(int i=0; i parameterType = parameterClassTypes.get(i); if(parameterType!=null){ if(parameterType.isArray()) { int arrayDepth = 1; Class componentType = parameterType.getComponentType(); while(true) { if(componentType.isArray()) { ++arrayDepth; componentType = componentType.getComponentType(); }else { args.append(componentType.getName()); for (int j = 0; j < arrayDepth; j++) { args.append("[]"); } break; } } }else { args.append(parameterType.getName()); } }else { args.append(""); } } return String.format("%1$s(%2$s)", name(), args); } @Override @io.qt.QtUninvokable public final String toString() { return methodSignature(); } /** *

See QMetaMethod::invoke(QObject *object, QGenericReturnArgument returnValue, QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()) const

*/ @io.qt.QtUninvokable public final Object invoke(QObject object, Object... args) throws IllegalArgumentException, io.qt.QUnsuccessfulInvocationException { return invoke(object, Qt.ConnectionType.AutoConnection, args); } /** *

See QMetaMethod::invoke(QObject *object, Qt::ConnectionType connectionType, QGenericReturnArgument returnValue, QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()) const

*/ @io.qt.QtUninvokable public final Object invoke(QObject object, Qt.ConnectionType connection, Object... args) throws IllegalArgumentException, io.qt.QUnsuccessfulInvocationException { if(!isValid()) throw new io.qt.QUnsuccessfulInvocationException("Cannot invoke an invalid QMetaMethod."); if(parameterCount() != args.length) { throw new IllegalArgumentException(String.format("Wrong number of arguments. expected: %2$s, given: %1$s", args.length, parameterCount())); } { QMetaObject enclosingMetaObject = enclosingMetaObject(); QMetaObject objectMO = object.metaObject(); if(objectMO!=enclosingMetaObject && !objectMO.inherits(enclosingMetaObject)) { throw new IllegalArgumentException(String.format("Given object is not an instance of %1$s", enclosingMetaObject.className())); } } if(connection==Qt.ConnectionType.BlockingQueuedConnection && object.thread()==QThread.currentThread()) { throw new io.qt.QUnsuccessfulInvocationException("Blocking-queued invocation on object whose thread is the current thread is not allowed."); } Class[] argClassTypes = new Class[1+parameterCount()]; Class returnType = returnClassType(); argClassTypes[0] = returnType==null ? void.class : returnType; if(argClassTypes[0]!=void.class && argClassTypes[0]!=Void.class) { if(connection==Qt.ConnectionType.QueuedConnection) { throw new io.qt.QUnsuccessfulInvocationException("Unable to invoke methods with return values in queued connections."); }else if(connection==Qt.ConnectionType.AutoConnection) { if(QThread.currentThread() != object.thread()) { throw new io.qt.QUnsuccessfulInvocationException("Unable to invoke methods with return values in queued connections (auto connection with different threads)."); } } } java.util.List> parameterClassTypes = parameterClassTypes(); for(int i=0; i[] argClassTypes, int connection, Object[] args); /** *

See QMetaMethod::invokeOnGadget(void *gadget, QGenericReturnArgument returnValue, QGenericArgument val0 = QGenericArgument(nullptr), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()) const

*/ @io.qt.QtUninvokable public final Object invokeOnGadget(Object object, Object... args) throws IllegalArgumentException, io.qt.QUnsuccessfulInvocationException { if(!isValid()) throw new io.qt.QUnsuccessfulInvocationException("Cannot invoke an invalid QMetaMethod."); if(parameterCount() != args.length) { throw new IllegalArgumentException(String.format("Wrong number of arguments. expected: %2$s, given: %1$s", args.length, parameterCount())); } { QMetaObject enclosingMetaObject = enclosingMetaObject(); QMetaObject objectMO = QMetaObject.forGadget(object); if(objectMO!=enclosingMetaObject && !objectMO.inherits(enclosingMetaObject)) { throw new IllegalArgumentException(String.format("Given gadget is not an instance of %1$s", enclosingMetaObject.className())); } } Class[] argClassTypes = new Class[1+parameterCount()]; Class returnType = returnClassType(); argClassTypes[0] = returnType==null ? void.class : returnType; java.util.List> parameterClassTypes = parameterClassTypes(); for(int i=0; i[] argClassTypes, Object[] args); @io.qt.QtUninvokable public final java.lang.reflect.Method toReflectedMethod() { if(isValid()) { switch(methodType()) { case Method: case Slot: java.lang.reflect.AccessibleObject reflected = toReflected(); if(reflected instanceof java.lang.reflect.Method){ return (java.lang.reflect.Method)reflected; } try { java.util.List> parameterTypes = parameterClassTypes(); return this.enclosingMetaObject().type().getDeclaredMethod(name().toString(), parameterTypes.toArray(new Class[parameterTypes.size()])); } catch (NoSuchMethodException | SecurityException e) { } break; default: throw new IllegalArgumentException("Method " + this + " is a " + methodType().name().toLowerCase() + "."); } } return null; } @io.qt.QtUninvokable private native java.lang.reflect.AccessibleObject toReflected(); @io.qt.QtUninvokable public final java.lang.reflect.Constructor toReflectedConstructor() { if(isValid()) { if(methodType()==MethodType.Constructor) { java.lang.reflect.AccessibleObject reflected = toReflected(); if(reflected instanceof java.lang.reflect.Constructor){ return (java.lang.reflect.Constructor)reflected; } try { java.util.List> parameterTypes = parameterClassTypes(); return this.enclosingMetaObject().type().getDeclaredConstructor(parameterTypes.toArray(new Class[parameterTypes.size()])); } catch (NoSuchMethodException | SecurityException e) { } }else { throw new IllegalArgumentException("Method " + this + " is not a constructor."); } } return null; } @io.qt.QtUninvokable public final QMetaObject.AbstractSignal toSignal(QObject sender) { if(isValid()) { if(methodType()==MethodType.Signal) { return io.qt.internal.QtJambiInternal.findSignal(sender, name().toString(), parameterClassTypes().toArray(new Class[parameterCount()])); }else { throw new IllegalArgumentException("Method " + this + " is not a signal."); } } return null; } @io.qt.QtUninvokable public static QMetaMethod fromSignal(QMetaObject.AbstractSignal signal) { QMetaMethod method = null; io.qt.QtSignalEmitterInterface containingObject = signal.containingObject(); if(containingObject instanceof QObject) { if(signal.methodIndex()>=0) { method = ((QObject)containingObject).metaObject().methodByIndex(signal.methodIndex()); }else{ java.util.List> signalTypeClasses = signal.argumentTypes(); method = ((QObject)containingObject).metaObject().method(signal.name(), signalTypeClasses.toArray(new Class[signalTypeClasses.size()])); } } return method; } public static QMetaMethod fromReflectedConstructor(java.lang.reflect.Constructor constructor) { QMetaObject mo = QMetaObject.forType(constructor.getDeclaringClass()); if(mo!=null) { return mo.constructor(constructor.getParameterTypes()); } return null; } public static QMetaMethod fromReflectedMethod(java.lang.reflect.Method method) { Class declaringClass = method.getDeclaringClass(); QMetaMethod qmethod = null; QMetaObject mo = QMetaObject.forType(declaringClass); if(mo!=null) { Object[] ok = {method}; qmethod = methodFromMethod(mo.metaObjectPointer, ok); if(qmethod==null && ok[0]==null) { qmethod = mo.method(method.getName(), method.getParameterTypes()); } } return qmethod; } private static native QMetaMethod methodFromMethod(long metaObjectPointer, Object[] method); private static QMetaMethod fromMethodImpl(QMetaObject.AbstractSlot method) { io.qt.internal.QtJambiInternal.LambdaInfo info = io.qt.internal.QtJambiInternal.lamdaInfo(method); if(info!=null && info.lambdaArgs.isEmpty()) { if(info.reflectiveMethod!=null) return fromReflectedMethod(info.reflectiveMethod); if(info.reflectiveConstructor!=null) return fromReflectedConstructor(info.reflectiveConstructor); } return null; } public static QMetaMethod fromMethod(QMetaObject.Method0 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method1 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method2 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method3 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method4 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method5 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method6 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method7 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method8 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Method9 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot0 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot1 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot2 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot3 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot4 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot5 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot6 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot7 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot8 method) { return fromMethodImpl(method); } public static QMetaMethod fromMethod(QMetaObject.Slot9 method) { return fromMethodImpl(method); } @Override public QMetaMethod clone() { return clone_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } private native QMetaMethod clone_native(long __this_nativeId); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy