精华内容
下载资源
问答
  • LuaJava
    2021-02-12 09:31:55

    Overview

    LuaJava is a scripting tool for Java. The goal of this tool is to allow scripts written

    in Lua to manipulate components developed in Java. LuaJava allows Java components to be

    accessed from Lua using the same syntax that is used for accessing Lua`s native objects,

    without any need for declarations or any kind of preprocessing.

    LuaJava also allows Java to implement an interface using Lua. This way any interface can

    be implemented in Lua and passed as parameter to any method, and when called, the

    equivalent function will be called in Lua, and it's result passed back to Java.

    LuaJava is available under the same

    license as Lua 5.1, that is, it can be used

    at no cost for both academic and commercial purposes.

    An Ukrainian translation

    of this page is available, kindly provided by the Jeweell team.

    Status

    LuaJava version 1.1 for Lua 5.1.1 is now available for download.

    Dependencies

    LuaJava uses LuaBinaries 5.1.1 and Java JDK 1.4 or above.

    Download

    LuaJava can be download from the LuaForge

    page. If you are using

    LuaBinaries 5.1.1

    a Windows pre-compiled version of LuaJava can also be found at the same

    LuaForge page.

    Credits

    LuaJava 1.1LuaJava 1.1 was developed by Thiago Ponte.LuaJava 1.0LuaJava 1.0 was developed by Thiago Ponte and sponsored by Ideais,

    Fábrica Digital, Finep and CNPq.LuaJava 1.0 betaLuaJava 1.0 beta was reimplemented to be compatible with Lua 5.0 and with new features

    of Java 1.3.

    LuaJava 1.0 beta was developed by Thiago Ponte and Rafael Rizzato with contributions from

    Jo?o Machado, Danilo Tuler and Roberto Ierusalimschy.LuaJava for Lua 3.1LuaJava was first developed by Carlos Cassino.

    Contact us

    For more information please contact

    us. Comments are welcome!

    You can also reach other Kepler developers and users on the Kepler Project

    mailing list.

    更多相关内容
  • LuaJava-开源

    2021-07-10 06:37:35
    LuaJava 是 Java 的脚本工具。 这个工具的目标是允许 Lua 操作用 Java 开发的组件。 LuaJava 还允许在 Lua 中实现 Java 接口。
  • 可以在64位和32位的win7下使用的luajava 1.1版本
  • luajava-x32-x64.zip

    2020-02-27 11:50:58
    luajava-1.1.jar的64位版本和32位版本,包含对应luajava-1.1.dll文件 欢迎大家下载 亲测可用
  • luajava-1.1.0

    2017-11-14 16:35:23
    luajava-1.1.0luajava-1.1.0luajava-1.1.0luajava-1.1.0luajava-1.1.0
  • 部分例子源代码 博文链接:https://univasity.iteye.com/blog/493339
  • luajava从5.1升级到5.3

    2018-10-17 21:48:33
    luajava从5.1升级到5.3
  • LuaJava5.1

    2012-09-05 13:07:14
    LuaJava.dll LuaJava源代码,在java中调用Lua语言必备
  • luajava-master.zip

    2019-06-02 23:36:33
    LUAJIT源代码相比原有的LUA解释器性能提升10倍以上,大家都很喜欢
  • LuaJava一款使 Lua 可以方便的调用 Java 的工具.介绍LuaJava is a scripting tool for Java. The goal of this tool is to allow scripts written in Lua to manipulate components developed in Java.It allows ...

    LuaJava

    一款使 Lua 可以方便的调用 Java 的工具.

    介绍

    LuaJava is a scripting tool for Java. The goal of this tool is to allow scripts written in Lua to manipulate components developed in Java.

    It allows Java components to be accessed from Lua using the same syntax that is used for accessing Lua`s native objects, without any need

    for declarations or any kind of preprocessing. LuaJava also allows Java to implement an interface using Lua. This way any interface can be

    implemented in Lua and passed as parameter to any method, and when called, the equivalent function will be called in Lua, and it's result

    passed back to Java.

    与原 luajava 项目变化

    适配 LuaJava 至 lua5.3.5 版本

    Lua 源码升级至 5.3.5 版本

    Windows 下一键编译

    其他系统请自行编译

    编译

    Windows 一键编译

    配置 java 环境.

    运行 OneKeyCompile.bat.

    编译完成,可在项目根目录中看到 luajava-1.0.dll、luajava-1.0.jar 2个文件.

    若需编译好的文件,直接到 release 下载

    08f08e58b23307d2f0455deb24ce8235.png

    其他系统,自行编译测试

    测试

    交互方式执行 lua

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console

    直接执行 lua 文件

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console xxx.lua

    部分例子

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console ./test/awtTest.lua

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console ./test/simpleLuaFile.lua

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console ./test/testMap.lua

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console ./test/swingTest.lua

    java -cp luajava-1.0.jar org/keplerproject/luajava/Console

    ff008de52451d5f4d1ebe96af4863781.png

    其它

    如果你有好的建议或者发现bug,欢迎给我提 issue.

    如果该repo对大家有帮助,给个 star 鼓励鼓励吧.

    常见问题

    Can't load AMD 64-bit .dll on a IA 32-bit platform

    答:这个是由于 JAVA 虚拟机版本和 DLL 位数不一致,比如 64 位虚拟机配 64 位 DLL.

    致谢

    展开全文
  • LuaJava 是一款专门用于在java下执行lua脚本,该工具的主要目的是允许编写Lua脚本去操作Java组件,不需要任何声明以及任何的预处理。LuaJava 也允许Java去实现一个接口来调用Lua,这样任何的Lua相关接口功能都可以被...
  • luajava的64位版本和32位版本 欢迎大家下载 亲测可用
  • 依赖包(附件有下载):包名类型操作系统luajava-1.1.jarjarALLlibluajava-1.1.so.solinuxluajava-1.1.dll.dllwindowswindows:将luajava-1.1.dll拷贝到java.libary.path目录(通过System.getProperty("java.library....

    依赖包(附件有下载):

    包名

    类型

    操作系统

    luajava-1.1.jar

    jar

    ALL

    libluajava-1.1.so

    .so

    linux

    luajava-1.1.dll

    .dll

    windows

    windows:

    将luajava-1.1.dll拷贝到java.libary.path目录(通过System.getProperty("java.library.path")可以知道)

    linux:

    将libluajava-1.1.so拷贝到java.libary.path目录(通过System.getProperty("java.library.path")可以知道)

    如果linux有问题,则按以下操作重新编译.so文件

    1.编译&安装Lua

    tar -zxvf lua-5.1.5.tar.gz

    cd lua-5.1.5

    make linux install

    注:64位系统需要先编辑src/Makefile,在CFLAGS上添加-fPIC。

    2.编译与安装Luajava

    tar -zxvf luajava-1.1.tar.gz

    cd luajava-1.1

    修改 config文件,添加JAVA_HOME=/broadtech/javaweb/jdk1.6.0_25

    make

    3.部署。

    将编译好的libluajava-1.1.so拷贝到java.libary.path目录(通过System.getProperty("java.library.path")可以知道),

    luajava-1.1.jar拷贝到$JAVA_HOME\jre\lib\ext目录

    4、重启项目

    注:LuaJava1.1缺少了JNIEXPORT void JNICALL Java_org_keplerproject_luajava_LuaState__1pushInteger (JNIEnv * env , jobject jobj , jobject cptr , jint number) 方法的实现,编译前可编辑src/c/luajava.c加入以下代码实现再make

    /************************************************************************

    *   JNI Called function

    *      Lua Exported Function

    ************************************************************************/

    JNIEXPORT void JNICALL Java_org_keplerproject_luajava_LuaState__1pushInteger

    (JNIEnv * env , jobject jobj , jobject cptr , jint number)

    {

    lua_State * L = getStateFromCPtr( env , cptr );

    lua_pushinteger( L, ( lua_Integer ) number );

    }

    LuaUtil.java

    /**

    * 调用Lua脚本

    * @author chamcon

    * @date 2013-11-07 15:58:48

    */

    public class LuaUtil {

    public static List PUBLIC_LUA_FILES = new ArrayList();

    public static Logger logger = Logger.getLogger(LuaUtil.class);

    static {

    //配置公共函数lua文件

    //PUBLIC_LUA_FILES.add("");

    }

    /**

    * 执行Lua脚本

    */

    public static String execLuaFunc(String lua,String funcName,String value){

    //依赖库文件要放到java.library.path下

    logger.debug("java.library.path:"+System.getProperty("java.library.path"));

    LuaState L = LuaStateFactory.newLuaState();

    // 加载lua标准库,否则一些lua基本函数无法使用

    L.openLibs();

    //加载公共函数文件

    if(!PUBLIC_LUA_FILES.isEmpty()){

    for(int i=0;i

    L.LdoFile(PUBLIC_LUA_FILES.get(i));

    }

    }

    //加载函数串

    L.LdoString(lua);

    //调用函数名

    L.getField(LuaState.LUA_GLOBALSINDEX, funcName);

    //设置参数

    L.pushString(value);

    //调用

    L.call(1, 1);

    //设置返回对象

    L.setField(LuaState.LUA_GLOBALSINDEX, "RESULT");

    LuaObject lobj = L.getLuaObject("RESULT");

    //获取返回值

    String res = lobj.getString();

    L.close();

    if(res == null) return "";

    return res;

    }

    }

    Java调用Lua脚本(热载实现)

    前言: Lua作为解析执行的脚本语言, 往往是易变逻辑编写的首选语言, 尤其是在游戏领域. C/C++和Lua的结合, 往往了标配. 比如Redis, Nginx其对Lua的支持, 也是杠杠的. 当然 ...

    Redis进阶实践之八Lua的Cjson在Linux下安装、使用和用C#调用Lua脚本

    一.引言         学习Redis也有一段时间了,感触还是颇多的,但是自己很清楚,路还很长,还要继续.上一篇文章简要的介绍了如何在Linux环境下安装Lua,并介绍了在Linux环境下如何编写L ...

    lua调用java java调用lua[转载]

    转载:http://dualface.github.io/blog/2013/01/01/call-java-from-lua/LuaJavaBridge - Lua 与 Java 互操作的简单解决方 ...

    Java调用Lua(转)

    Java 调用 Lua app发版成本高,覆盖速度慢,覆盖率页低.一些策略上的东西如果能够从服务端控制会方便一些.所以考虑使用Lua这种嵌入式语言作为策略实现,Java则是宿主语言. 总体上看是一个模 ...

    java调用python脚本并向python脚本传递参数

    1.安装Eclipse 先安装jdk,再安装Eclipse,成功后开始建立py_java项目,在这个项目的存储目录SRC下建立test包,在test包中New-Class,新建MyDemo类,建好完成 ...

    用C#调用Lua脚本

    用C#调用Lua脚本 一.引言 学习Redis也有一段时间了,感触还是颇多的,但是自己很清楚,路还很长,还要继续.上一篇文章简要的介绍了如何在Linux环境下安装Lua,并介绍了在Linux环境下如何 ...

    通过Java调用Python脚本

    在进行开发的过程中,偶尔会遇到需要使用Java调用Python脚本的时候,毕竟Python在诸如爬虫,以及科学计算等方面具有天然的优势.最近在工作中遇到需要在Java程序中调用已经写好的Python程 ...

    Java 调用 shell 脚本详解

    这一年的项目中,有大量的场景需要Java 进程调用 Linux的bash shell 脚本实现相关功能. 从之前的项目中拷贝的相关模块和网上的例子来看,有个别的“陷阱”造成调用shell 脚本在某些特 ...

    (转)java调用python脚本

    这篇博客旨在吐血分享今天遇到的java调用python脚本遇到的坑,折腾了3个多小时终于可以跑通了,代码超级短,但网上的好多资料都是抄来抄去的,很少有能够直接跑通的,尤其是针对你的python文件中用 ...

    随机推荐

    微信小程序-基础内容组件

    icon 图标 示例:

    centos7安装数据库

    centos7的yum源中貌似没有正常安装MySQL时的mysql-server. 那么就需要从官网下载了. 下面是安装mysql的命令: # wget http://dev.mysql.com/ge ...

    c++中vector的学习

    根据各种做题,发现数组并不是很适用于各种情况,当涉及到内存占用的时候,数组可能就没有vector的优势了,而vector,动态数组,比较适合某些情况. 接下来看看比较基本的vector用法: 1 #i ...

    C# Java间进行RSA加密解密交互(二)

    原文:C# Java间进行RSA加密解密交互(二) 接着前面一篇文章C# Java间进行RSA加密解密交互,继续探讨这个问题. 在前面,虽然已经实现了C# Java间进行RSA加密解密交互,但是还是与 ...

    delegate和event

    经过查阅资料和自己的理解整理出来的,欢迎大家指教. delegate和event 何时使用: 异步的时候,比如加载完成通知. 需要回调的时候,比如按钮点击.动画播放结束等. 发送事件通知的时候. 比如 ...

    sql语句去除重复记录(多表连接的查询)

    --处理表重复记录(查询和删除) /********************************************************************************** ...

    ECSTORE AJAX提交的实现

    今天向大家介绍在ecstore中怎样使用ajax提交数据 1

    Bootstrap定制(一)less入门及编译

    第一篇博,希望支持. 近期在开发一个项目,项目前端定位于bootstrap,遂花了少许时间研究了bootstrap,将其整理整理,与众人共享. bootstrap官方的定制,功能还算完善,但是基于we ...

    几个获取Windows系统信息的Delphi程序

    1.获取windows版本信息 可以通过Windows API函数GetVersionEx来获得. 具体程序如下: Procedure Tform1.Button1Click(sender:TObje ...

    raise RuntimeError("autoconf error") RuntimeError: autoconf error

    pip 安装模块时遇到下错误,没有粘贴全,差不多都是这样.这个情况是 pip 安装模块 需要 gcc 及 python-devle 支持, ubuntu 是 python-dev ,使用Yum 安装即 ...

    展开全文
  • luajava-1.1-x64-lua51

    2017-02-07 10:29:07
    luajava-1.1-x64-lua51
  • LuaJava:LuaJava 初探

    千次阅读 2015-10-23 16:39:18
    LuaJava是java语言的一个脚本工具. 目标是在Java允许通过编写java脚本来操作组件.

     

    1 -LuaJava是什么以及LuaJava特点

    LuaJava is a scripting tool for Java. The goal of this tool is to allow scripts written in Lua to manipulate components developed in Java.

    LuaJava allows Java components to be accessed from Lua using the same syntax that is used for accessing Lua`s native objects, without any need for declarations or any kind of preprocessing.

     

    LuaJava also allows Java to implement an interface using Lua. This way any interface can be implemented in Lua and passed as parameter to any method, and when called, the equivalent function will be called in Lua, and it's result passed back to Java.

     

    LuaJava是java语言的一个脚本工具. 目标是在Java允许通过编写java脚本来操作组件.

    LuaJava允许不需要预先声明或者其他任何的预处理来相互方法. Lua语法来访问java组件,也可以是java来访问Lua语言中的对象


    2- LuaJava历史

    LuaJava 1.1
    LuaJava 1.1 was developed by Thiago Ponte.


    LuaJava 1.0
    LuaJava 1.0 was developed by Thiago Ponte and sponsored by Ideais, Fábrica Digital, Finep and CNPq.


    LuaJava 1.0 beta
    LuaJava 1.0 beta was reimplemented to be compatible with Lua 5.0 and with new features of Java 1.3. LuaJava 1.0 beta was developed by Thiago Ponte and Rafael Rizzato with contributions from João Machado, Danilo Tuler and Roberto Ierusalimschy.


    LuaJava for Lua 3.1
    LuaJava was first developed by Carlos Cassino.

    LuaJava项目由Carlos Cassino 创建,但是主要贡献者 为Thiago Ponte .


    3- LuaJava版本更新

    1.1 [24/Jan/2007]
    changes to comply with Lua 5.1 API;
    included LUA_MULTRET as a LuaState constant;
    corrected bug on LuaObject.call on the order of the results.
    1.0 [22/Jun/2005]
    improved error handling;
    dropped JDK 1.3 compatibility;
    windows binaries compatible with LuaBinaries 5.0.2 Release 2;
    new documentation format.
    1.0 Beta 4 [21/Jan/2005]
    package renamed to "org.keplerproject.luajava";
    LuaObject.getLuaState is now public;
    new function LuaObject.type();
    JavaFunction.foo() renamed to JavaFunction.execute();
    method called by javaLoadLib now can return an int.
    1.0 Beta 3 [21/Sep/2004]
    new function in lua luajava.loadLib, that opens libraries for Lua written in Java;
    function LuaState.setGlobal now receives String, to work like Lua setglobal;
    JavaFunction.foo() throws LuaException;
    new function LuaState.pushString(byte[]);
    Bugs linking some lua functions to Java;
    minor bug fixes.
    1.0 Beta 2 [07/Jul/2004]
    now supports multi-threading;
    new function LuaState.close() that should be called to close the state;
    LuaState was missing some functions;
    many bug fixes.
    1.0 Beta 1 [28/Jun/2004] LuaJava version 1.1 uses LuaBinaries 5.1.1 and Java JDK 1.4 or above.
    Lua语言的主要版本在2004年开始,Java语言2007年已经发布 Java SE 6.0 (1.6.0)版本,对于Lua5.1.1是Lua最重要的一个大版本更新,Lua语言特性基本囊括完全。java版本1.6.0也提供了较完全的特性。
    4 LuaJava中的C语言代码
    在LuaJava中包括了一个luajava.c文件。 luajava.c module is the implementation of luajava's dinamic library.
    In this module lua's functions are exported to be used in java by jni,
    and also the functions that will be used and exported to lua so that
    Java Objects' functions can be called.


    LuaJava.c文件模块主要实现luajava的动态链接库。
    在C文件中,lua 语言脚本函数可以使java语言通过Java Native Interface技术来实现访问。
    同时,Lua 可以调用Java 对象的函数。

    2- LuaJava 中关键的Java源代码

     

    CPtr 类,用来抽象C语言中指针。

    /**
     * An abstraction for a C pointer data type.  A CPtr instance represents, on
     * the Java side, a C pointer.  The C pointer could be any <em>type</em> of C
     * pointer. 
     */
    //对于C 指针数据类型的一种抽象,一个CPtr可以用来在java语言中表示C指针。C指针可以是任何类型的
    public class CPtr
    {
    	public boolean equals(Object other)
    	{
    		if (other == null)
    			return false;
    		if (other == this)
    	    return true;
    		if (CPtr.class != other.getClass())
    	    return false;
    		return peer == ((CPtr)other).peer;
       }
    
        /* Pointer value of the real C pointer. Use long to be 64-bit safe. */
        private long peer;
        protected long getPeer()
        {
        	return peer;
        }
        CPtr() {}
    }

    LuaState.java 关键类的主要源代码

    public class LuaState extends java.lang.Object {}

    /**
     * LuaState if the main class of LuaJava for the Java developer.
     * LuaState is a mapping of most of Lua's C API functions.
     * LuaState also provides many other functions that will be used to manipulate 
     * objects between Lua and Java.
     * @author Thiago Ponte
     */
    //LuaState 是java编程人员主要操作的类.LuaState是Lua C API 函数的映射类. LuaState 同样提供了很多方法可以操作Lua 和Java对象.
    //LuaState java类与luajava.c文件相对应。这两个文件的主要功能:
    //1 -通过luajava.c文件来使用Lua语言提供的功能
    //2 -LuaState.java文件通过Java Native interface 技术把Lua C API 映射成 Lua Java API 
    //这样就可以通过Java语言来提供 Java和Lua语言交互的功能。(对象相互使用,方法相互调用,对象生命周期管理等)
    //3-LuaState同时也建立了与LuaJava.c文件的关联
    public class LuaState
    {
      private final static String LUAJAVA_LIB = "luajava-1.1"; //定义dll动态类库的名称
    
      final public static Integer LUA_GLOBALSINDEX  = new Integer(-10002);
      final public static Integer LUA_REGISTRYINDEX = new Integer(-10000);
    
      final public static Integer LUA_TNONE     = new Integer(-1);
      final public static Integer LUA_TNIL      = new Integer(0);
      final public static Integer LUA_TBOOLEAN  = new Integer(1);
      final public static Integer LUA_TLIGHTUSERDATA = new Integer(2);
      final public static Integer LUA_TNUMBER   = new Integer(3);
      final public static Integer LUA_TSTRING   = new Integer(4);
      final public static Integer LUA_TTABLE    = new Integer(5);
      final public static Integer LUA_TFUNCTION = new Integer(6);
      final public static Integer LUA_TUSERDATA = new Integer(7);
      final public static Integer LUA_TTHREAD   = new Integer(8);
    
      /**
       * Specifies that an unspecified (multiple) number of return arguments
       * will be returned by a call.
       */
      final public static Integer LUA_MULTRET   = new Integer(-1);
      
      /*
       * error codes for `lua_load' and `lua_pcall'
       */
      /**
       * a runtime error.
       */
      final public static Integer LUA_ERRRUN    = new Integer(1);
      
      /**
       * 
       */
      final public static Integer LUA_YIELD     = new Integer(2);
      
      /**
       * syntax error during pre-compilation.
       */
      final public static Integer LUA_ERRSYNTAX = new Integer(3);
      
      /**
       * memory allocation error. For such errors, Lua does not call 
       * the error handler function.
       */
      final public static Integer LUA_ERRMEM    = new Integer(4);
      
      /**
       * error while running the error handler function.
       */
      final public static Integer LUA_ERRERR    = new Integer(5);
    
      /**
       * Opens the library containing the luajava API
       */
      static
      {
        System.loadLibrary(LUAJAVA_LIB);
      }
    
      private CPtr luaState;
    
      private int stateId;
    
      /**
       * Constructor to instance a new LuaState and initialize it with LuaJava's functions
       * @param stateId
       */
      protected LuaState(int stateId)
      {
        luaState = _open();
        luajava_open(luaState, stateId);
        this.stateId = stateId;
      }
    
      /**
       * Receives a existing state and initializes it
       * @param luaState
       */
      protected LuaState(CPtr luaState)
      {
        this.luaState = luaState;
        this.stateId = LuaStateFactory.insertLuaState(this);
        luajava_open(luaState, stateId);
      }
      /********************* Lua Native Interface *************************/
    
      private synchronized native CPtr _open();
      private synchronized native void _close(CPtr ptr);
      private synchronized native CPtr _newthread(CPtr ptr);
    
      // Stack manipulation
      private synchronized native int  _getTop(CPtr ptr);
      private synchronized native void _setTop(CPtr ptr, int idx);
      private synchronized native void _pushValue(CPtr ptr, int idx);
      private synchronized native void _remove(CPtr ptr, int idx);
      private synchronized native void _insert(CPtr ptr, int idx);
      private synchronized native void _replace(CPtr ptr, int idx);
      private synchronized native int  _checkStack(CPtr ptr, int sz);
      
      private synchronized native void _xmove(CPtr from, CPtr to, int n);
    
      // Access functions
      private synchronized native int    _isNumber(CPtr ptr, int idx);
      private synchronized native int    _isString(CPtr ptr, int idx);
      private synchronized native int    _isCFunction(CPtr ptr, int idx);
      private synchronized native int    _isUserdata(CPtr ptr, int idx);
      private synchronized native int    _type(CPtr ptr, int idx);
      private synchronized native String _typeName(CPtr ptr, int tp);
    
      private synchronized native int _equal(CPtr ptr, int idx1, int idx2);
      private synchronized native int _rawequal(CPtr ptr, int idx1, int idx2);
      private synchronized native int _lessthan(CPtr ptr, int idx1, int idx2);
    
      private synchronized native double _toNumber(CPtr ptr, int idx);
      private synchronized native int    _toInteger(CPtr ptr, int idx);
      private synchronized native int    _toBoolean(CPtr ptr, int idx);
      private synchronized native String _toString(CPtr ptr, int idx);
      private synchronized native int    _objlen(CPtr ptr, int idx);
      private synchronized native CPtr   _toThread(CPtr ptr, int idx);
    
      // Push functions
      private synchronized native void _pushNil(CPtr ptr);
      private synchronized native void _pushNumber(CPtr ptr, double number);
      private synchronized native void _pushInteger(CPtr ptr, int integer);
      private synchronized native void _pushString(CPtr ptr, String str);
      private synchronized native void _pushString(CPtr ptr, byte[] bytes, int n);
      private synchronized native void _pushBoolean(CPtr ptr, int bool);
    
      // Get functions
      private synchronized native void _getTable(CPtr ptr, int idx);
      private synchronized native void _getField(CPtr ptr, int idx, String k);
      private synchronized native void _rawGet(CPtr ptr, int idx);
      private synchronized native void _rawGetI(CPtr ptr, int idx, int n);
      private synchronized native void _createTable(CPtr ptr, int narr, int nrec);
      private synchronized native int  _getMetaTable(CPtr ptr, int idx);
      private synchronized native void _getFEnv(CPtr ptr, int idx);
    
      // Set functions
      private synchronized native void _setTable(CPtr ptr, int idx);
      private synchronized native void _setField(CPtr ptr, int idx, String k);
      private synchronized native void _rawSet(CPtr ptr, int idx);
      private synchronized native void _rawSetI(CPtr ptr, int idx, int n);
      private synchronized native int  _setMetaTable(CPtr ptr, int idx);
      private synchronized native int  _setFEnv(CPtr ptr, int idx);
    
      private synchronized native void _call(CPtr ptr, int nArgs, int nResults);
      private synchronized native int  _pcall(CPtr ptr, int nArgs, int Results, int errFunc);
    
      // Coroutine Functions
      private synchronized native int _yield(CPtr ptr, int nResults);
      private synchronized native int _resume(CPtr ptr, int nargs);
      private synchronized native int _status(CPtr ptr);
      
      // Gargabe Collection Functions
      final public static Integer LUA_GCSTOP       = new Integer(0);
      final public static Integer LUA_GCRESTART    = new Integer(1);
      final public static Integer LUA_GCCOLLECT    = new Integer(2);
      final public static Integer LUA_GCCOUNT      = new Integer(3);
      final public static Integer LUA_GCCOUNTB     = new Integer(4);
      final public static Integer LUA_GCSTEP       = new Integer(5);
      final public static Integer LUA_GCSETPAUSE   = new Integer(6);
      final public static Integer LUA_GCSETSTEPMUL = new Integer(7);
      private synchronized native int  _gc(CPtr ptr, int what, int data);
    
      // Miscellaneous Functions
      private synchronized native int    _error(CPtr ptr);
      private synchronized native int    _next(CPtr ptr, int idx);
      private synchronized native void   _concat(CPtr ptr, int n);
    
      // Some macros
      private synchronized native void _pop(CPtr ptr, int n);
      private synchronized native void _newTable(CPtr ptr);
      private synchronized native int  _strlen(CPtr ptr, int idx);
      private synchronized native int  _isFunction(CPtr ptr, int idx);
      private synchronized native int  _isTable(CPtr ptr, int idx);
      private synchronized native int  _isNil(CPtr ptr, int idx);
      private synchronized native int  _isBoolean(CPtr ptr, int idx);
      private synchronized native int  _isThread(CPtr ptr, int idx);
      private synchronized native int  _isNone(CPtr ptr, int idx);
      private synchronized native int  _isNoneOrNil(CPtr ptr, int idx);
      
      private synchronized native void _setGlobal(CPtr ptr, String name);
      private synchronized native void _getGlobal(CPtr ptr, String name);
      
      private synchronized native int  _getGcCount(CPtr ptr);
    
    
      // LuaLibAux
      private synchronized native int _LdoFile(CPtr ptr, String fileName);
      private synchronized native int _LdoString(CPtr ptr, String string);
      //private synchronized native int _doBuffer(CPtr ptr, byte[] buff, long sz, String n);
      
      private synchronized native int    _LgetMetaField(CPtr ptr, int obj, String e);
      private synchronized native int    _LcallMeta(CPtr ptr, int obj, String e);
      private synchronized native int    _Ltyperror(CPtr ptr, int nArg, String tName);
      private synchronized native int    _LargError(CPtr ptr, int numArg, String extraMsg);
      private synchronized native String _LcheckString(CPtr ptr, int numArg);
      private synchronized native String _LoptString(CPtr ptr, int numArg, String def);
      private synchronized native double _LcheckNumber(CPtr ptr, int numArg);
      private synchronized native double _LoptNumber(CPtr ptr, int numArg, double def);
      
      private synchronized native int    _LcheckInteger(CPtr ptr, int numArg);
      private synchronized native int    _LoptInteger(CPtr ptr, int numArg, int def);
      
      private synchronized native void _LcheckStack(CPtr ptr, int sz, String msg);
      private synchronized native void _LcheckType(CPtr ptr, int nArg, int t);
      private synchronized native void _LcheckAny(CPtr ptr, int nArg);
      
      private synchronized native int  _LnewMetatable(CPtr ptr, String tName);
      private synchronized native void _LgetMetatable(CPtr ptr, String tName);
      
      private synchronized native void _Lwhere(CPtr ptr, int lvl);
      
      private synchronized native int  _Lref(CPtr ptr, int t);
      private synchronized native void _LunRef(CPtr ptr, int t, int ref);
      
      private synchronized native int  _LgetN(CPtr ptr, int t);
      private synchronized native void _LsetN(CPtr ptr, int t, int n);
      
      private synchronized native int _LloadFile(CPtr ptr, String fileName);
      private synchronized native int _LloadBuffer(CPtr ptr, byte[] buff, long sz, String name);
      private synchronized native int _LloadString(CPtr ptr, String s);
    
      private synchronized native String _Lgsub(CPtr ptr, String s, String p, String r);
      private synchronized native String _LfindTable(CPtr ptr, int idx, String fname, int szhint);
      
      
      private synchronized native void _openBase(CPtr ptr);
      private synchronized native void _openTable(CPtr ptr);
      private synchronized native void _openIo(CPtr ptr);
      private synchronized native void _openOs(CPtr ptr);
      private synchronized native void _openString(CPtr ptr);
      private synchronized native void _openMath(CPtr ptr);
      private synchronized native void _openDebug(CPtr ptr);
      private synchronized native void _openPackage(CPtr ptr);
      private synchronized native void _openLibs(CPtr ptr);
    
    }




     

    public class LuaObject extends java.lang.Object {}

    This class represents a Lua object of any type. A LuaObject is constructed by a LuaState object using one of the four methods:

     •LuaState.getLuaObject(String globalName)
    •LuaState.getLuaObject(LuaObject parent, String name)
    •LuaState.getLuaObject(LuaObject parent, Number name)
    •LuaState.getLuaObject(LuaObject parent, LuaObject name)
    •LuaState.getLuaObject(int index)

    The LuaObject will represent only the object itself, not a variable or a stack index, so when you change a string, remember that strings are immutable objects in Lua, and the LuaObject you have will represent the old one.

    LuaJava allows you to implement a class in Lua, like said before. If you want to create this proxy from Java, you should have a LuaObject representing the table that has the functions that implement the interface.

    From this LuaObject you can call the createProxy(String implements). This method receives the string with the name of the interfaces implemented by the object separated by comma.

     

    LuaObject类是LuaJava的核心。如下内容节选自:LuaJava-A Scripting Tool for Java的论文部分章节。

    The Implementation of LuaJava


    LuaJava is implemented throughproxies:

    whenever a Java object is passed to Lua, a Lua object is created to represent it. 
    Conversely, when a Lua object is passed to Java, a Java object is used to represent it.
    Because Lua and Java have quite different run time behaviors, we have used different techniques to implement the Lua proxies and the Java proxies.



    LuaJava是通过代理来实现的:当Java 对象传递到Lua语言中,一个Lua Object对象将创建来表示java对象。
    反过来,当一个Lua对象传递到Java语言中,一个java对象将创建处理用来表示Lua对象。
    因为Lua和java语言有着不同的运行时行为,所以使用不同的技术来实现Lua代理和java代理。

    A Lua proxy (that is, a Lua object that represents a Java object) is implemented using the fallback mechanism
    A fallback, in Lua, is a function that can be used to modify the default behavior of the language for some events.
    In LuaJava we use fallbacks to modify the way proxy fields are accessed and modified. 
    So, a proxy is a nearly empty Lua object that intercepts any access to its (usually empty) fields.
    A proxy has also at least one non empty field, that stores a reference to the Java object it represents.

     

    Above shows what happens when we call a proxy’s method: 
    The first step, shown in the solid box, is the access to a field called move.

    This access triggers a fallback; the fallback, having access to the proxy (and thus to the Java
    object it represents) and the method name, uses Java’s reflexive API to obtain information about that method (or methods, since Java allows overloading).
    The fallback then returns aclosure with this information.

    The second step, shown in the dashed box, is triggered when the closure is applied to the given arguments.
    At this point the closure selects a method suited to the actual parameters, converts them from Lua to Java, executes the actual invocation, and converts back the result, if there is one.
    As a performance improvement, at the end of the invocation a closure with the selected method is stored in field move of the proxy.
    Therefore, in the following calls the first step can be avoided.
    This same algorithm, with small modifications, is used to access instance  variables and array elements.
    Similarly, the fallback over field modifications is used to handle assignments to array elements and instance variables.


    The implementation of Java proxies for Lua objects is a little more complex.
    As Java has type declarations, each Java proxy must have a predefined type. Moreover, because Java is statically typed, we must have a class for each type of proxy that we create. LuaJava builds these classes on demand.First, it writes the class bytecode in a byte array, Next, it uses a ClassLoader to dynamically load this new class into the program.
    A Java type can be an interface or a class. The proxies for these two kinds  of types are slightly different.
    In both cases, the proxy has an instance variable with a reference to the Lua object it represents.

    For a proxy that implements an interface, LuaJava create a new class, compatible with the given interface,with all its methods coded as follows: 
    First, they convert their arguments to  Lua;
            next, they call the corresponding method in the Lua object;  
            Finally, they  convert eventual results back to Java.
    When the proxy represents a class, LuaJava implements it as a subclass of the original class.
    This subclass redefines all the original methods;
    each new method, when called, first checks whether the corresponding method in Lua exist. 
    If the Lua method is present, it is called, like in the case of interfaces.

    However, if the Lua object has no such method, the subclass method detects this absence, and calls instead itssuper implementation, that is, the method from the original class. 
    In this way, a Lua object implementing a class “inherits” from the class any method that it does not redefine.



    A Lua object representing a Java interface does not need to implementall its methods, quite the opposite.
    After all, one of the goals of a scriptinglanguage is to allow rapid prototyping. With LuaJava, we need to implement
    only the methods that will be used. Moreover, we can add methods to ourobject incrementally, even after it has been passed to Java.

    LuaJava is part of a larger project, called LuaOrb [CIR98, ICR98]. LuaOrb integrates a Lua script not only with Java components, but also with CORBAand COM components.

    展开全文
  • 里面有.so文件和编译.so文件所需要的.c/.h文件
  • centos64位编译luajava1.1

    2015-03-09 16:55:27
    luajava1.1.rar,包括libluajava-1.1.so跟luajava-1.1.jar,是本人在centos64位环境下根据源码编译生成,经检验可用。
  • luajava.zip

    2019-07-18 15:16:27
    这是64位的luajava.jar和luajava.dll文件。这是64位的luajava.jar和luajava.dll文件。
  • windows luajava安装

    2018-10-18 09:55:27
    1.首先,下载luajava 下载地址:http://luaforge.net/projects/luajava/ 最开始是下的luajava-1.1-win32-lua51.zip,将里面的jar包放入工程依赖包里,但总是提示出错 org.springframework.web.util....
  • How does one get the value back from a Lua function call in LuaJava.Lets say I have calc.lua:function foo(n) return n*2 endI call the function in Java as follows:LuaState luaState;this.luaState = LuaS...
  • LuaJava: 一步一步调试LuaJava

    千次阅读 2015-10-23 16:33:39
    通过调试LuaJava源文件来学习和了解LuaJava. LuaJava 作为Java的脚本工具,核心代码通过luajava.c文件来实现,luajava是通过jni 技术实现的. 一步一步调试LuaJava源代码同时有助于学习JNI技术.
  • Lua-1.0.113 luajava

    2018-11-07 19:53:12
    Lua-1.0.113 luajava luajava
  • luajava实例及jar包,dll动态链接库

    热门讨论 2009-03-15 19:09:32
    luajava-1.1.zip (实例) luajava-1.1-win32-lua51.zip (luajava-1.1.jar,luajava-1.1.dll)
  • luajava-1.1.jar

    2008-01-17 10:28:42
    luajava-1.1.jar
  • OSCHINA 的 iPhone 客户端源码,可直接在 App Store上搜索“开源中国”来安装此app
  • 搞了一整天几乎要发狂了,终于完成了一点点androLua和luajava的初步探究。下面总结一下吧:在上一篇博文里面已经说明了如何在Android中嵌入lua脚本,按照步骤操作应该可以完成android中使用简单的lua脚本,进行动态...
  • 编译luajava

    2020-06-20 00:00:30
    最近代码转为游戏服务器编写,战斗模块使用了luajava调用战斗脚本内容,使用mac无法找到对应的luajava的安装包;开始了漫长的查询之路,不太顺利,在此备忘下,后续会继续更新. 唯一找到一个可以在mac环境下打出来包的...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 54,865
精华内容 21,946
关键字:

luajava

java 订阅
友情链接: xuanzhuan.zip