什么是语言绑定?

发布于 2024-07-05 01:46:33 字数 209 浏览 12 评论 0原文

我的好朋友维基百科对于这个问题没有给我很好的答复。 那么:

  • 什么是语言绑定?
  • 它们是如何工作的?

特别是访问用 Y 语言编写的库中用 X 语言编写的代码中的函数。

My good friend, Wikipedia, didn't give me a very good response to that question. So:

  • What are language bindings?
  • How do they work?

Specifically accessing functions from code written in language X of a library written in language Y.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

挽清梦 2024-07-12 01:46:33

在 Flex (Actionscript 3) 中。

数据绑定将一个对象中的属性值复制到另一个对象中的属性。 您可以绑定以下对象的属性:Flex 组件、Flex 数据模型和 Flex 数据服务。

提供数据的对象属性称为源属性。 接收数据的对象属性称为目标属性。

以下示例将 TextInput 组件的文本属性(源属性)绑定到 Label 组件的文本属性(目标属性),以便在 TextInput 组件中输入的文本由 Label 组件显示:

<mx:TextInput id="LNameInput"></mx:TextInput>
...
<mx:Label text="{LNameInput.text}"></mx:Label>

数据绑定通常是简单的将模型绑定到用户界面组件的方法。 例如,您有一个具有 FirstName 属性的类。 在 Flex 中,您可以通过将文本框的值设置为 {Object.FirstName} 来轻松将该属性绑定到文本框。 然后,每次 FirstName 属性发生更改时,文本框都会更新,而无需您编写任何代码来监视该属性的更改。

希望有帮助。

马特

In Flex (Actionscript 3). Source

A data binding copies the value of a property in one object to a property in another object. You can bind the properties of following objects: Flex components, Flex data models, and Flex data services.

The object property that provides the data is known as the source property. The object property that receives the data is known as the destination property.

The following example binds the text property of a TextInput component (the source property) to the text property of a Label component (the destination property) so that text entered in the TextInput component is displayed by the Label component:

<mx:TextInput id="LNameInput"></mx:TextInput>
...
<mx:Label text="{LNameInput.text}"></mx:Label>

Data binding is usually a simple way to bind a model to user interface components. For example, you have a class with a FirstName property. In flex you could easily bind that property to a textbox by setting the value of the textbox to {Object.FirstName}. Then, every time that FirstName property changes, the textbox will be updated without requiring you to write any code to monitor that property for changes.

Hope that helps.

Matt

白云不回头 2024-07-12 01:46:33

好的,现在问题已经澄清了,这并不真正相关,所以我将其移至 一个新问题

绑定通常指的是一个事物到另一个事物的映射 - 即数据源到表示对象。 它通常指将数据库或类似源(XML 文件、Web 服务等)中的数据绑定到演示控件或元素 - 想想 HTML 中的列表或表格、组合框或桌面软件中的数据网格。

...如果您对这种绑定感兴趣,请继续阅读...

您通常必须将表示元素绑定到数据源,而不是相反。 这将涉及某种映射 - 即您希望数据源中的哪些字段出现在输出中。

有关多种环境的更多信息,请参阅:

Okay, now the question has been clarified, this isn't really relevant so I'm moving it to a new question

Binding generally refers to a mapping of one thing to another - i.e. a datasource to a presentation object. It can typically refer to binding data from a database, or similar source (XML file, web service etc) to a presentation control or element - think list or table in HTML, combo box or data grid in desktop software.

...If that's the kind of binding you're interested in, read on...

You generally have to bind the presentation element to the datasource, not the other way around. This would involve some kind of mapping - i.e. which fields from the datasource do you want to appear in the output.

For more information in a couple of environments see:

念﹏祤嫣 2024-07-12 01:46:33

假设您创建了一个 C 库来将内容发布到 stackoverflow。 现在您希望能够使用 Python 中的相同库。 在这种情况下,您将为您的库编写 Python 绑定。

另请参阅 SWIG:http://www.swig.org

Let's say you create a C library to post stuff to stackoverflow. Now you want to be able to use the same library from Python. In this case, you will write Python bindings for your library.

Also see SWIG: http://www.swig.org

唐婉 2024-07-12 01:46:33

在代码库的上下文中,绑定是在两种编程语言之间桥接的包装库,以便为一种语言编写的库也可以在另一种语言中隐式使用。

例如,libsvn 是 Subversion 的 API,是用 C 语言编写的。如果您想从 Java 代码中访问 Subversion,您可以使用 libsvn-java。 libsvn-java 依赖于安装的 libsvn,因为 libsvn-java 只是 Java 编程语言和 libsvn 之间的桥梁,提供仅调用 libsvn 函数来完成实际工作的 API。

In the context of code libraries, bindings are wrapper libraries that bridge between two programming languages so that a library that was written for one language can also be implicitly used in another language.

For example, libsvn is the API for Subversion and was written in C. If you want to access Subversion from within Java code you can use libsvn-java. libsvn-java depends on libsvn being installed because libsvn-java is a mere bridge between the Java programming language and libsvn, providing an API that merely calls functions of libsvn to do the real work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文