equal
deleted
inserted
replaced
795 } else { |
795 } else { |
796 return QScriptDeclarativeClass::Value(); |
796 return QScriptDeclarativeClass::Value(); |
797 } |
797 } |
798 } |
798 } |
799 |
799 |
|
800 int QDeclarativeObjectMethodScriptClass::enumType(const QMetaObject *meta, const QString &strname) |
|
801 { |
|
802 QByteArray str = strname.toUtf8(); |
|
803 QByteArray scope; |
|
804 QByteArray name; |
|
805 int scopeIdx = str.lastIndexOf("::"); |
|
806 if (scopeIdx != -1) { |
|
807 scope = str.left(scopeIdx); |
|
808 name = str.mid(scopeIdx + 2); |
|
809 } else { |
|
810 name = str; |
|
811 } |
|
812 for (int i = meta->enumeratorCount() - 1; i >= 0; --i) { |
|
813 QMetaEnum m = meta->enumerator(i); |
|
814 if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) |
|
815 return QVariant::Int; |
|
816 } |
|
817 return QVariant::Invalid; |
|
818 } |
|
819 |
800 QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::call(Object *o, QScriptContext *ctxt) |
820 QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::call(Object *o, QScriptContext *ctxt) |
801 { |
821 { |
802 MethodData *method = static_cast<MethodData *>(o); |
822 MethodData *method = static_cast<MethodData *>(o); |
803 |
823 |
804 if (method->data.flags & QDeclarativePropertyCache::Data::HasArguments) { |
824 if (method->data.flags & QDeclarativePropertyCache::Data::HasArguments) { |
808 QVarLengthArray<int, 9> argTypes(argTypeNames.count()); |
828 QVarLengthArray<int, 9> argTypes(argTypeNames.count()); |
809 |
829 |
810 // ### Cache |
830 // ### Cache |
811 for (int ii = 0; ii < argTypeNames.count(); ++ii) { |
831 for (int ii = 0; ii < argTypeNames.count(); ++ii) { |
812 argTypes[ii] = QMetaType::type(argTypeNames.at(ii)); |
832 argTypes[ii] = QMetaType::type(argTypeNames.at(ii)); |
813 if (argTypes[ii] == QVariant::Invalid) |
833 if (argTypes[ii] == QVariant::Invalid) |
|
834 argTypes[ii] = enumType(method->object->metaObject(), argTypeNames.at(ii)); |
|
835 if (argTypes[ii] == QVariant::Invalid) |
814 return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii))))); |
836 return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii))))); |
815 } |
837 } |
816 |
838 |
817 if (argTypes.count() > ctxt->argumentCount()) |
839 if (argTypes.count() > ctxt->argumentCount()) |
818 return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments"))); |
840 return Value(ctxt, ctxt->throwError(QLatin1String("Insufficient arguments"))); |