什么是二进制标准 [英] What is a Binary Standard

查看:293
本文介绍了什么是二进制标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在读COM,有一个提到的二进制标准和如何使语言独立可能。
什么是二进制标准实际上?
在我看来,二进制将意味着机器级代码,如果它意味着机器语言怎么独立?

I have been reading up COM, there is a mention of binary standard and how that makes language independence possible.. Whats binary standard actually? In my mind, binary would mean machine level code, and if it means machine language how can that be independent at all?

推荐答案

在它的最底层,COM实际上只是一个二进制级标准,描述两个软件如何沟通。它是二进制的,因为它 100%独立于语言,它不依赖源代码,但只在内存中的特定结构布局。

At its lowest level, COM is really only a binary-level standard that describes how two pieces of software can communicate. It's binary because it's 100% language independant, it does not rely on source code, but only on a specific layout of structures in memory.

在我看来,最好的文章是 COM程序员手册。这个着名的二进制标准在文档开头解释,我在这里引用:

In my opinion, the best article to start with is The COM Programmer's Cookbook. This famous binary standard is explained at the beginning of the document that I quote here:


服务用户和实现之间的分离是由
间接函数调用。 COM接口只不过是一个名为
的函数指针表
(方法),每个表都记录了
行为。行为记录在接口
函数的参数和对象
实例内的状态的模型。在实例内的模型的描述将说没有
多于使
接口中的其他方法的行为可理解所需的。 函数表被称为
vtable

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.

接口实际上是指向vtable的指针。 vtables是
,通常由多个实例共享,因此方法需要一个不同的
指针,以便能够找到该接口附加的对象
。这是接口指针,vtable指针是接口的客户端可以访问的唯一
事件。
设计,这种安排与C ++类的虚拟方法调用约定
相匹配,因此COM接口与C ++
抽象类是二进制兼容的。
/ p>

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.

它附带的模式代表内存中的二进制标准布局:

And the schema that comes with it represents the binary standard layout in memory:

这篇关于什么是二进制标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆