Coder Social home page Coder Social logo

opensourcegamedeveloper / lua-for-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qtiuto/lua-for-android

0.0 0.0 0.0 6.29 MB

A high-performance bridge for lua and java or c in Android with mutil-thread and almost all java features supported

License: BSD 3-Clause "New" or "Revised" License

Java 74.99% Makefile 0.08% C++ 10.68% C 12.82% Lua 1.38% CMake 0.01% HTML 0.04%

lua-for-android's Introduction

Build Status Download

General

This is a friendly and high performance bridge for java and lua in android. With it, you can call java functions, use java objects easily in lua. It supports auto method deduction, auto data conversion, import java package/class, multi-thread, exception handling, class extension/implementation and other facilitative features. See wiki for more detailed description.

Module luaffi, luasec, luasocket are optional package. And module lfs is embeded.

Both lua(5.1-5.3) and luajit(2.0.5 and 2.1.0-beta3) are supported.

Configure Android.mk by setting LUA_LIB :=(lua or luajit) to choose the proper version.

Currently, lua 5.3.5 is in lua dir and luajit 2.1.0 beta-3 is in luajit dir.

Load the lib by LibLoader.java in the module app or add System.loadLibrary("luadroid.so") to your code.

Module lib is the true library that you can embedded into your code.

Module app is a lua editor for running test in android.

Module luaffi is the ffi lib for luadroid to invoke c apis, and it requires luadroid.so to be statically linked

Performance

Under release mode, the bridge around 3+ times slower than jni because of consumption in method deduction and data conversion. Yet, if no argument provided, it is almost as fast as jni.

Around 2500000 method call(Math.abs) per second on my Oneplus 5 device. Around 1800000 member access plus with method call(Math.abs) per second. Note that if you run it in debug mode,CheckJni mode is enabled by the vm,and it will take away more than half of the efficiency.

Here is the test script:

using "java.lang"
--for method call test
local abs=Math.abs
local t=os.clock()
for i=1,2.5e6 do
    abs(0)
end
print(os.clock()-t)

--for member access test
t=os.clock()
for i=1,1.8e6 do
    Math.abs(0)
end
print(os.clock()-t)

Documentation

For documentation,see wiki.

Email:

[email protected]

lua-for-android's People

Contributors

qtiuto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.