Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[unity]更新master 生成各种报错 #619

Closed
mingxxming opened this issue Jan 5, 2022 · 4 comments
Closed

[unity]更新master 生成各种报错 #619

mingxxming opened this issue Jan 5, 2022 · 4 comments
Assignees

Comments

@mingxxming
Copy link
Contributor

error log | 日志或报错信息

NullReferenceException: Object reference not set to an instance of an object
Puerts.Editor.Generator.GenClass.MethodGenInfo+<>c.b__6_2 (System.Linq.IGrouping2[TKey,TElement] lst) (at Assets/Scripts/GCore/Puerts/Src/Editor/Generator.cs:781) System.Linq.Enumerable+SelectEnumerableIterator2[TSource,TResult].MoveNext () (at <19f157554c514bbc99588e176244e375>:0)
System.Linq.Enumerable+WhereEnumerableIterator1[TSource].ToArray () (at <19f157554c514bbc99588e176244e375>:0) System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable1[T] source) (at <19f157554c514bbc99588e176244e375>:0)
Puerts.Editor.Generator.GenClass.MethodGenInfo.FromType (System.Type type, System.Boolean isCtor, System.Collections.Generic.List1[T] overloads, System.Collections.Generic.List1[T] extensionOverloads) (at Assets/Scripts/GCore/Puerts/Src/Editor/Generator.cs:748)
Puerts.Editor.Generator.GenClass.TypeGenInfo.FromType (System.Type type, System.Collections.Generic.List`1[T] genTypes) (at Assets/Scripts/GCore/Puerts/Src/Editor/Generator.cs:398)
Puerts.Editor.Generator.Menu.GenerateCode (System.String saveTo, System.Boolean tsOnly, System.Boolean esmMode) (at Assets/Scripts/GCore/Puerts/Src/Editor/Generator.cs:1532)
Puerts.Editor.Generator.Menu.GenerateCode () (at Assets/Scripts/GCore/Puerts/Src/Editor/Generator.cs:1450)

context | 编译/运行环境

unityeditor 2021.2.7

how to reproduce | 复现步骤

生成wrap

more | 其他

生成出来的代码,诸如:
private static void M_<>iFixBaseProxy_play(IntPtr isolate, IntPtr info, IntPtr self, int paramLen, long data)

@zombieyang zombieyang self-assigned this Jan 5, 2022
@zombieyang zombieyang changed the title 更新master 生成各种报错 [unity]更新master 生成各种报错 Jan 5, 2022
@zombieyang
Copy link
Contributor

我在2021使用demo的binding列表测试没有问题
能否提供一下你设置的binding列表以及具体报错的wrap class?

@mingxxming
Copy link
Contributor Author

绑定列表:
typeof(Color),
typeof(object[]),
typeof(Debug),
typeof(Vector3),
typeof(Vector2),
typeof(GameObject),
typeof(Transform),
typeof(Vector4),
typeof(Quaternion),
typeof(List),
typeof(List),
typeof(List),
typeof(List),
typeof(Dictionary<string, List>),
typeof(Dictionary<int, List>),
typeof(Dictionary<int, List>),
typeof(Dictionary<int, List>),
typeof(Time),
typeof(Transform),
typeof(Component),
typeof(GameObject),
typeof(UnityEngine.Object),
typeof(Delegate),
typeof(ParticleSystem),
typeof(RenderMode),
typeof(Behaviour),
typeof(MonoBehaviour),
typeof(Logger),
typeof(QualitySettings),
typeof(Application),
typeof(GCore.F64),
typeof(GCore.FVector3)

出错的结构:
namespace GCore {

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct F64 {
    public long val;

    public F64(float v) {
        val = (long)((double)v * 4294967296.0f);
    }

    public F64(int v) {
        val = (long)v << 32;
    }

    public F64(long v) {
        val = v;
    }

    public static implicit operator F64(long v) {
        return new F64(v);
    }

    public static implicit operator F64(int v) {
        return new F64(v);
    }

    public static implicit operator F64(float v) {
        return new F64(v);
    }

    public override string ToString() {
        return ToFloat().ToString();
    }

    public float ToFloat() {
        return val / 4294967296.0f;
    }
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct FVector3 {
    public long X;
    public long Y;
    public long Z;

    public FVector3(F64 x, F64 y, F64 z) {
        this.X = x.val;
        this.Y = y.val;
        this.Z = z.val;
    }

    public FVector3(long x=0 , long y=0, long z=0) {
        this.X = x;
        this.Y = y;
        this.Z = z;
    }

    public FVector3(int x = 0, int y = 0, int z = 0) {
        this.X = ((long)x << 32);
        this.Y = ((long)y << 32);
        this.Z = ((long)z << 32);
    }

    public FVector3(float x = 0, float y = 0, float z = 0) {
        this.X = (new F64(x)).val;
        this.Y = (new F64(y)).val;
        this.Z = (new F64(z)).val;
    }

    public override string ToString() {
        return string.Format("({0},{1},{2})", X.ToFloat(), Y.ToFloat(), Z.ToFloat());
    }

}

}

@mingxxming
Copy link
Contributor Author

另外这段代码加上THREAD_SAFE有错误:
public JSObject ExecuteModule(string filename)
{
if (loader.FileExists(filename))
{
#if THREAD_SAFE
lock (this) {
#endif
IntPtr resultInfo = PuertsDLL.ExecuteModule(isolate, filename);
if (resultInfo == IntPtr.Zero)
{
string exceptionInfo = PuertsDLL.GetLastExceptionInfo(isolate);
throw new Exception(exceptionInfo);
}
JSObject result = StaticTranslate.Get(Idx, isolate, NativeValueApi.GetValueFromResult, resultInfo, false);
PuertsDLL.ResetResult(resultInfo);
#if THREAD_SAFE
}
#endif
return result;//未定义
}
else
{
throw new InvalidProgramException("can not find " + filename);
}
}

@zombieyang
Copy link
Contributor

这两个问题修复了,楼顶提到的那个

private static void M_<>iFixBaseProxy_play(IntPtr isolate, IntPtr info, IntPtr self, int paramLen, long data)

没有看见,有问题的话再open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants