Luainterface

来源:互联网 发布:注册表清理软件 编辑:程序博客网 时间:2024/04/30 21:19




1.  Introduction

The Microsoft .NET Framework aims to provide interoperability among several different languages through its Common Language Runtime (CLR) [13].

The CLR specification is being turned into ISO and ECMA standards  [14],  and  implementations  for  non-Windows  platforms  already  exist  [17,  18].   

Visual  Basic, JScript,  C#,  J#,  and C++ already have compilers for the CLR, written by Microsoft,  and compilers for several other languages are under development [2].

微软的.Net框架目标是在不同种语言之间通过CLR来实现互通。微软的CLR标准已经成为ISO 和ECMA 的标准。

通过在微软平台下面编写的Visual  Basic, JScript,  C#,  J#,  and C++  语言已经可以编译成CLR可以运行的语言。还有更多其他的语言正在发展在CLR下面运行。


 Lua is a scripting language designed for to be simple,  portable,  to have a small footprint,  and to be easily embeddable into other languages [8, 10].

Scripting languages are often used for connecting components written in other languages to form applications (“glue” code).

They are also used for building prototypes,  and as languages for configuration files. 

The dynamic nature of these languages allows the use of components without previous declaration of types and without the need for a compilation phase.

Nevertheless, they perform extensive type checking at runtime and provide detailed information in case of errors.  The combination of these features can increase developer productivity by a factor of two or more 。


Lua被设计成一种简单  可移植  灵活的脚步语言。并且很容易的内嵌到另外一种语言汇总。 脚步语言经常作为粘合语言。脚步语言经常作为其他语言的配置文件。



This work presents LuaInterface, a library for the CLR that allows Lua scripts to access the object model of the CLR, the Common Type System (CTS), turning Lua into a scripting language for components written in any language that runs in the CLR.

LuaInterface is part of the Lua.NET project for integration of Lua into the CLR [9]. 


LuaInterface所做的工作就是作为 在CLR中允许Lua脚本可以获取CLR 的对象。并且把CTS对象变成LUA语言中的对象。

LuaInterface 是 把LUA语言和CLR 相结合成LUA.NET项目的一个库。



With LuaInterface, Lua scripts can instantiate CTS types, access their fields, and call their methods (both static and instance), all using the standard Lua syntax.

CLR applications can run Lua code, acess Lua data, call Lua functions, and register CLR methods as functions.

Applications can use Lua as a language for their configuration scripts or as an embedded scripting language, and Lua cripts can glue together different

components.

Besides these consumer facilities there is also a limited support for dynamically creating new CTS types, but it will not be covered in this paper. 


通过LuaInterface ,LUA脚本可以实例化CTS对象,获取CTS对象的成本变量,调用成员方法。同时,CLR应用程序可以使用标准的LUA语法来允许lua代码,获取lua数据

调用lua方法,并且在LUA中注册CLR方法。

应用程序也可以使用LUA脚本语言作为自己的配置文件或者使用LUA语言来粘合不同的组件。



Lua is dynamically typed, so it needs no type declarations to instantiate or use CLR objects.           

 It checks at runtime the correctness of each instantiation, field access, or method call.          

 LuaInterface makes extensive  use  of  the  reflexive  features  of  the  CLR,  without  the  need  of  preprocessing  or  creating  stubs

for each object that needs to be accessed.

Its implementation required no changes to the Lua interpreter: the interpreter is compiled to an unmanaged dynamic linked library and the CLR interfaces with it using

P/Invoke. 

LUA语言是一个动态类型语言,在LUA中没有类型声明,所以在使用和实例化CLR 对象时,不需要声明CLR对象的类型。

在运行时期间,在每一次实例化,获取成员变量,调用方法时都要检查对象。

通过LuaInterface 可以不用编译CLR程序来拓展使用CLR的模型特性。



LuaInterface 就是C# 和LUA语言的粘合层。 在C++和lua之间,Luabind等一些库充当语言之间的粘合库。







0 0