Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ialex32x committed Aug 9, 2019
2 parents 6d6b249 + 738f508 commit 7c3e773
Show file tree
Hide file tree
Showing 16 changed files with 405 additions and 65 deletions.
18 changes: 17 additions & 1 deletion unity/Assets/Duktape/Editor/BindingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,23 @@ public string GetDuktapePusher(Type type)
{
return "duk_push_delegate";
}
return "duk_push_any";
if (type.IsValueType)
{
if (type.IsPrimitive)
{
return "duk_push_primitive";
}
if (type.IsEnum)
{
return "duk_push_enumvalue";
}
return "duk_push_structvalue";
}
if (type == typeof(string))
{
return "duk_push_primitive";
}
return "duk_push_classvalue";
}

public static string GetTSVariable(string name)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 79 additions & 1 deletion unity/Assets/Duktape/Plugins/Android/libs/x86/libduktape.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 31 additions & 2 deletions unity/Assets/Duktape/Source/DuktapeAux.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.RegularExpressions;
using UnityEngine;

namespace Duktape
Expand Down Expand Up @@ -40,6 +41,33 @@ public static void PrintError(IntPtr ctx, int idx, string filename)
err = DuktapeDLL.duk_safe_to_string(ctx, idx);
}

if (duk_source_position != default_duk_source_position)
{
var errlines = err.Split('\n');
err = "";
var reg = new Regex(@"^\s+at\s(.+)\s\((.+\.js):(\d+)\)(.*)$", RegexOptions.Compiled);
for (var i = 0; i < errlines.Length; i++)
{
var line = errlines[i];
var matches = reg.Matches(line);
if (matches.Count == 1)
{
var match = matches[0];
if (match.Groups.Count >= 4)
{
var funcName = match.Groups[1].Value;
var fileName = match.Groups[2].Value;
var lineNumber = 0;
int.TryParse(match.Groups[3].Value, out lineNumber);
var extra = match.Groups.Count >= 5 ? match.Groups[4].Value : "";
var sroucePosition = duk_source_position(ctx, funcName, fileName, lineNumber);
err += $" at {sroucePosition}{extra}\n";
continue;
}
}
err += line + "\n";
}
}
if (filename != null)
{
Debug.LogError($"[JSError][{filename}] {err}");
Expand Down Expand Up @@ -116,6 +144,7 @@ public static int duk_print(IntPtr ctx)
var fileName = DuktapeDLL.duk_safe_to_string(ctx, -1);
DuktapeDLL.duk_pop_n(ctx, 4);
stacktrace += (duk_source_position ?? default_duk_source_position)(ctx, funcName, fileName, lineNumber);
stacktrace += "\n";
}
else
{
Expand All @@ -137,9 +166,9 @@ public static string default_duk_source_position(IntPtr ctx, string funcName, st
{
funcName = "[anonymous]";
}
return $"{funcName} ({fileName}:{lineNumber})\n";
return $"{funcName} ({fileName}:{lineNumber})";
}
return $"{funcName} (<native code>)\n";
return $"{funcName} (<native code>)";
}

[AOT.MonoPInvokeCallback(typeof(DuktapeDLL.duk_c_function))]
Expand Down
Loading

0 comments on commit 7c3e773

Please sign in to comment.