gpt4 book ai didi

.net - 什么是二进制标准

转载 作者:行者123 更新时间:2023-12-04 02:24:45 25 4
gpt4 key购买 nike

我一直在阅读 COM,其中提到了二进制标准以及它如何使语言独立性成为可能。实际上什么是二进制标准?在我看来,二进制意味着机器级代码,如果它意味着机器语言,那它怎么可能完全独立呢?

最佳答案

在最低级别,COM 实际上只是描述两个软件如何通信的二进制级别标准。它是二进制的,因为它100% 语言无关,它不依赖于源代码,而只依赖于内存中结构的特定布局。

在我看来,最好的开始文章是The COM Programmer's Cookbook .这个著名的二进制标准在我在这里引用的文档的开头进行了解释:

The separation between service user and implementation is done by indirect function calls. A COM interface is nothing more than a named table of function pointers (methods), each of which has documented behavior. The behavior is documented in terms of the interface function's parameters and a model of the state within the object instance. The description of the model within the instance will say no more than is required to make the behavior of the other methods in the interface understandable. The table of functions is referred to as a vtable.

An interface is actually a pointer to a vtable. The vtables are usually shared by multiple instances, so the methods need a different pointer to be able to find the object that the interface is attached to. This is the interface pointer, and the vtable pointer is the only thing that is accessible from it by clients of the interface. By design, this arrangement matches the virtual method-calling convention of C++ classes, so a COM interface is binary-compatible with a C++ abstract class.

而它自带的schema代表了内存中的二进制标准布局:

COM VTABLE

关于.net - 什么是二进制标准,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23325785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com