Giter VIP home page Giter VIP logo

purescript's Issues

windows平台跑Demo的时候会出问题

今天一直在尝试,打了个windows下的il2cpp来测试,遇到了很多dll相关的主要是路径的问题,最后到了这里返回的res是-1,然后就不能继续下去了
image
按照我的理解,从ScriptEngine.Setup调用SetupMono启动TestEntry.dll这里应该是对应了intepreter模式的入口调用,应该是比较关键的地方。
接下来我只能用调试mono的方式来看为什么调用出错了。如果仓库主能完善一下文档追加一些原理和问题的faq,再来一个可复现的demo就好了。

class的field不会导出在wrapper class中,如果这个field在mono内被引用,导出和构建过程不会有问题,但是运行之后才发现crash

可否在生成了wrapper class的dll之后,再生成一次运行在mono层的dll,这样可以在编译时就发现问题,防止到运行之后的crash问题。

binder.json 的CSharpIgnorTypes可以产生类似的问题,如果配置了某些被忽略的type,但是这些在mono层被引用到了,运行中如果某个地方引用到了相关的成员或者函数,会产生crash,而构建过程中这些问题不会暴露出来。

class内定义的delegate如果作为此class的构造函数的参数传入,会导致生成的UnityBind有语法错误,并且wrapper class的处理也有误

例如这个class:

public class TestDelegateAsCtorArg
{
    public delegate void Callback();

    public TestDelegateAsCtorArg(Callback callback)
    {
        SetCallBack(callback);
    }
    public void SetCallBack(Callback callback)
    {
        if(callback != null)
        {
            callback();
        }
    }
}

生成的wrapper class的代码:

......
public  global::TestDelegateAsCtorArg.Callback _TestDelegateAsCtorArg__ctor_callback;
public GCHandle _TestDelegateAsCtorArg__ctor_callback_ref;
static Delegate5605cacf TestDelegateAsCtorArg__ctor_callbackAction = OnTestDelegateAsCtorArg__ctor_callback;
static void OnTestDelegateAsCtorArg__ctor_callback(IntPtr arg0_h)
{
  Exception __e = null;
  try
  {
    var arg0Obj = ObjectStore.Get<global::TestDelegateAsCtorArg>(arg0_h);
    arg0Obj._TestDelegateAsCtorArg__ctor_callback();
  }
  catch(Exception e)
  {
    __e = e;
  }
  if(__e != null)
  ScriptEngine.OnException(__e.ToString());
}
public  global::TestDelegateAsCtorArg.Callback _TestDelegateAsCtorArg_SetCallBack_callback;
public GCHandle _TestDelegateAsCtorArg_SetCallBack_callback_ref;
static Delegate5605cacf TestDelegateAsCtorArg_SetCallBack_callbackAction = OnTestDelegateAsCtorArg_SetCallBack_callback;
static void OnTestDelegateAsCtorArg_SetCallBack_callback(IntPtr arg0_h)
{
	Exception __e = null;
	try
	{
		var arg0Obj = ObjectStore.Get<global::TestDelegateAsCtorArg>(arg0_h);
		arg0Obj._TestDelegateAsCtorArg_SetCallBack_callback();
	}
	catch(Exception e)
	{
		__e = e;
	}
	if(__e != null)
	ScriptEngine.OnException(__e.ToString());
}
......

public TestDelegateAsCtorArg(Callback callback)
{
  if(typeof(TestDelegateAsCtorArg) == GetWType())
  {
    var TestDelegateAsCtorArg__ctor_callback_p = Marshal.GetFunctionPointerForDelegate(TestDelegateAsCtorArg__ctor_callbackAction);
    var h = MonoBind.TestDelegateAsCtorArg__ctor_6(TestDelegateAsCtorArg__ctor_callback_p);
    ScriptEngine.CheckException();
    SetHandle(h);
    ObjectStore.Store(this, h);
  }
}
public void SetCallBack(Callback callback)
{
  _TestDelegateAsCtorArg_SetCallBack_callback = callback;
  ObjectStore.RefMember(this,ref _TestDelegateAsCtorArg_SetCallBack_callback_ref,_TestDelegateAsCtorArg_SetCallBack_callback);
  var TestDelegateAsCtorArg_SetCallBack_callback_p = Marshal.GetFunctionPointerForDelegate(TestDelegateAsCtorArg_SetCallBack_callbackAction);
  MonoBind.TestDelegateAsCtorArg_SetCallBack(this.Handle, TestDelegateAsCtorArg_SetCallBack_callback_p);
  ScriptEngine.CheckException();
  return ;
}

生成的UnityBind的代码:

static Delegatef55bb3df _EventDelegate__ctor_call;
static void OnEventDelegate__ctor_call(this global::EventDelegate arg0)
{
var arg0_h = ObjectStore.Store(arg0);
_EventDelegate__ctor_call(arg0_h);
ScriptEngine.CheckException();
}

[MonoPInvokeCallback(typeof(EventDelegate__ctor_12_Type))]
static IntPtr EventDelegate__ctor_12 (IntPtr call_p)
{
Exception __e = null;
try
{
	_EventDelegate__ctor_call = call_p == IntPtr.Zero ? null: Marshal.GetDelegateForFunctionPointer<Delegatef55bb3df>(call_p);
	var _value = new global::EventDelegate(thizObj.OnEventDelegate__ctor_call); //语法错误
	var _valueHandle = ObjectStore.Store(_value);
	return _valueHandle;
}
catch(Exception _e_)
{
	__e = _e_;
}
if(__e != null)
ScriptEngine.OnException(__e.ToString());
return default(IntPtr);
}

项目目前对于delegate的处理应该是将mono层传入的delegate作为function pointer,赋值给wrapper class的static成员。mono内的wrapper class传入的delegate没有正确赋值,UnityBInd内被封装之后的delegate的实例则依赖于class的实例来获得,而此时还在构造constructor的参数,无法获取到实例,导致最后生成的代码产生语法错误。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.