What is object marshalling?

后端 未结 10 978
后悔当初
后悔当初 2020-12-13 01:42

I have heard this concept used frequently, but I don\'t have a really good grasp of what it is.

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 02:16

    Marshalling is the conversion between a native type in c++ (HTMLElement, const wchar_t*) and the internal runtime representation that the virtual machine library in c++ uses (JSObject, MonoString etc.) to represent the virtual type / managed type that is visible to JS/C# etc. scripts running on the virtual machine (HTMLElement, System.String). P/Invoke performs automatic marshalling. Passing a System.String to a native call using P/Invoke causes a const wchar_t* to be passed to the native call as automatic marshalling takes place. When you use internal calls however, it will be passed as a MonoString, which the c++ function will have to marshal itself and then marshal whatever it needs to return to an internal runtime return type. Only blittable types don't need to be marshalled when using internal calls, for instance, int, which is a System.Int32 is passed as a gint32, which is just an int.

提交回复
热议问题