|
@@ -45,6 +45,23 @@ namespace Jint.Runtime.Interop
|
|
{
|
|
{
|
|
parameters[i] = arguments[i];
|
|
parameters[i] = arguments[i];
|
|
}
|
|
}
|
|
|
|
+ else if (parameterType == typeof(JsValue[]) && arguments[i].IsArray())
|
|
|
|
+ {
|
|
|
|
+ // Handle specific case of F(params JsValue[])
|
|
|
|
+
|
|
|
|
+ var arrayInstance = arguments[i].AsArray();
|
|
|
|
+ var len = TypeConverter.ToInt32(arrayInstance.Get("length"));
|
|
|
|
+ var result = new JsValue[len];
|
|
|
|
+ for (var k = 0; k < len; k++)
|
|
|
|
+ {
|
|
|
|
+ var pk = k.ToString();
|
|
|
|
+ result[k] = arrayInstance.HasProperty(pk)
|
|
|
|
+ ? arrayInstance.Get(pk)
|
|
|
|
+ : JsValue.Undefined;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ parameters[i] = result;
|
|
|
|
+ }
|
|
else
|
|
else
|
|
{
|
|
{
|
|
if (!converter.TryConvert(arguments[i].ToObject(), parameterType, CultureInfo.InvariantCulture, out parameters[i]))
|
|
if (!converter.TryConvert(arguments[i].ToObject(), parameterType, CultureInfo.InvariantCulture, out parameters[i]))
|
|
@@ -73,6 +90,9 @@ namespace Jint.Runtime.Interop
|
|
throw new JavaScriptException(Engine.TypeError, "No public methods with the specified arguments were found.");
|
|
throw new JavaScriptException(Engine.TypeError, "No public methods with the specified arguments were found.");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Reduces a flat list of parameters to a params array
|
|
|
|
+ /// </summary>
|
|
private JsValue[] ProcessParamsArrays(JsValue[] jsArguments, IEnumerable<MethodInfo> methodInfos)
|
|
private JsValue[] ProcessParamsArrays(JsValue[] jsArguments, IEnumerable<MethodInfo> methodInfos)
|
|
{
|
|
{
|
|
foreach (var methodInfo in methodInfos)
|
|
foreach (var methodInfo in methodInfos)
|