org.keplerproject.luajava.LuaState Java Examples

The following examples show how to use org.keplerproject.luajava.LuaState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LuaScriptInvoker.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
private void initLuaContext(LuaState luaState){
	try {
		JavaFunction logfunction = new LogFunctionCallBack(luaState);
		logfunction.register("log");
		JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
		tostringfunction.register("tostring");
		luaState.pushJavaObject(ModuleContext.getInstance().getAppContext().getApplicationContext());
		luaState.setGlobal("context");
		luaState.pushJavaObject(ZjDroidLuaJavaAPI.getInstance());
		luaState.setGlobal("zjdroid");
	} catch (LuaException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
 
Example #2
Source File: LuaScriptInvoker.java    From AppTroy with Apache License 2.0 6 votes vote down vote up
private void initLuaContext(LuaState luaState){
    try {
        JavaFunction logfunction = new LogFunctionCallBack(luaState);
        logfunction.register("log");
        JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
        tostringfunction.register("tostring");
        JavaFunction bindfunction = new BindClassCallBack(luaState);
        bindfunction.register("bind");
        JavaFunction reflecttion = new ReflectCallBack(luaState);
        reflecttion.register("getMethod");
    } catch (LuaException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
 
Example #3
Source File: LuaEventMsgs.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void luaEventAchievementMsg(ConfigDynamicDataInfo configdynamicdatainfo)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getAchievementMsgs");
    luastate.pushJavaObject(listDao);
    luastate.pushJavaObject(configdynamicdatainfo);
    luamanager.callLua(2, 0);
}
 
Example #4
Source File: i.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void onSuccess(int l, Header aheader[], byte abyte0[])
{
    String s = Utils.getStringFromBytes(abyte0);
    j j1;
    j1 = (j)Utils.getGson().fromJson(s, cn/com/smartdevices/bracelet/lua/j);
    if (j1.a != 1)
    {
        Debug.i("chenee", (new StringBuilder()).append("get latest luaZipFile error (message:").append(j1.b).append(")").toString());
        return;
    }
    try
    {
        byte abyte1[] = Base64.decode(j1.c.b, 2);
        LuaZipFile luazipfile = new LuaZipFile();
        luazipfile.setVersion(j1.c.c);
        luazipfile.setZipFile(abyte1);
        LuaZipFileDao luazipfiledao = DaoManager.getInstance().getLuaZipFileDao();
        luazipfiledao.insertOrReplace(luazipfile);
        Keeper.keepLatestDBLuaVersion(j1.c.c);
        Debug.i("chenee", (new StringBuilder()).append("save DB luaZipFile onSuccess====(version:").append(j1.c.c).append(")").toString());
        a.resetLuaState();
        LuaState luastate = a.getLuaState();
        luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "setLocale");
        luastate.pushString(Locale.getDefault().toString());
        a.callLua(1, 0);
        Debug.i("chenee", (new StringBuilder()).append("zipfile count:").append(luazipfiledao.count()).toString());
        return;
    }
    catch (Exception exception)
    {
        Debug.e("chenee", (new StringBuilder()).append("get latest lua gson error!:").append(exception.getMessage()).toString());
    }
    return;
}
 
Example #5
Source File: LuaAction.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void doLuaAction(String s)
{
    Debug.i("chenee", (new StringBuilder()).append("-------------\n").append(s).toString());
    Debug.i("chenee", "--------------------\n");
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = LuaManager.getInstance().getLuaState();
    luastate.LdoString(s);
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "doAction");
    luastate.pushJavaObject(context);
    luastate.pushJavaObject(__instance);
    luamanager.callLua(2, 0);
}
 
Example #6
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void callLuaFunc(String s, EventGameUpdate eventgameupdate)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), s);
    eventgameupdate.getConfigInfo().setLuaAction(context);
    luastate.pushJavaObject(DaoManager.getInstance().getLuaListDao());
    luastate.pushJavaObject(eventgameupdate.getConfigInfo());
    luamanager.callLua(2, 0);
}
 
Example #7
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public String getGameInfo()
{
    setLocale(Locale.getDefault().toString());
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getGameInfo");
    luastate.pushJavaObject(cInfo);
    luamanager.callLua(1, 0);
    Debug.i("LuaEvent", (new StringBuilder()).append("get lua game info  =").append(cInfo.getGameInfo()).toString());
    return cInfo.getGameInfo();
}
 
Example #8
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public String getLuaVersion()
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getLuaVersion");
    luastate.pushJavaObject(cInfo);
    luamanager.callLua(1, 0);
    String s = cInfo.getLuaVersion();
    Debug.i("LuaEvent", (new StringBuilder()).append("get lua version from local =").append(cInfo.getLuaVersion()).toString());
    return s;
}
 
Example #9
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void setGoal()
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    de.greenrobot.daobracelet.LuaListDao lualistdao = DaoManager.getInstance().getLuaListDao();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "dayComplete");
    luastate.pushJavaObject(lualistdao);
    luastate.pushJavaObject(cInfo);
    luamanager.callLua(2, 0);
}
 
Example #10
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void setLocale(String s)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "setLocale");
    luastate.pushString(s);
    luamanager.callLua(1, 0);
}
 
Example #11
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void setRecord(ReportData reportdata)
{
    cInfo.setNewRecordReport(reportdata);
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    de.greenrobot.daobracelet.LuaListDao lualistdao = DaoManager.getInstance().getLuaListDao();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "newRecord");
    luastate.pushJavaObject(lualistdao);
    luastate.pushJavaObject(cInfo);
    luamanager.callLua(2, 0);
}
 
Example #12
Source File: LuaEvent.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void testAction()
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    LuaAction luaaction = LuaAction.getInstance(context);
    de.greenrobot.daobracelet.LuaListDao lualistdao = DaoManager.getInstance().getLuaListDao();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "doAction2");
    luastate.pushJavaObject(context);
    luastate.pushJavaObject(luaaction);
    luastate.pushJavaObject(lualistdao);
    luamanager.callLua(3, 0);
}
 
Example #13
Source File: LuaScriptInvoker.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void invokeScript(String script){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoString(script);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	
	luaState.close();
}
 
Example #14
Source File: LuaEventMsgs.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void luaEventActivityMsg(ConfigDynamicDataInfo configdynamicdatainfo)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getActivityMsgs");
    luastate.pushJavaObject(listDao);
    luastate.pushJavaObject(configdynamicdatainfo);
    luamanager.callLua(2, 0);
}
 
Example #15
Source File: LuaEventMsgs.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void luaEventDefaultMsg(ConfigDynamicDataInfo configdynamicdatainfo)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getDefaultMsgs");
    luastate.pushJavaObject(listDao);
    luastate.pushJavaObject(configdynamicdatainfo);
    luamanager.callLua(2, 0);
}
 
Example #16
Source File: LuaEventMsgs.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void luaEventSleepMsg(ConfigDynamicDataInfo configdynamicdatainfo)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getSleepMsgs");
    luastate.pushJavaObject(listDao);
    luastate.pushJavaObject(configdynamicdatainfo);
    luamanager.callLua(2, 0);
}
 
Example #17
Source File: LuaEventMsgs.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void luaEventSysInfoMsg(ConfigDynamicDataInfo configdynamicdatainfo)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getSysInfoMsgs");
    luastate.pushJavaObject(listDao);
    luastate.pushJavaObject(configdynamicdatainfo);
    luamanager.callLua(2, 0);
}
 
Example #18
Source File: LuaEventMsgs.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void testLuaImp(int i, ConfigDynamicDataInfo configdynamicdatainfo)
{
    LuaManager luamanager = LuaManager.getInstance();
    LuaState luastate = luamanager.getLuaState();
    luastate.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "getEventMsgs");
    luastate.pushJavaObject(listDao);
    luastate.pushJavaObject(configdynamicdatainfo);
    luastate.pushInteger(i);
    luamanager.callLua(3, 0);
}
 
Example #19
Source File: LuaManager.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void luaSendVersion()
{
    ConfigDynamicDataInfo configdynamicdatainfo = ConfigDynamicDataInfo.getInstance();
    String s = Keeper.readApkVersion();
    mLuaState.getField(LuaState.LUA_GLOBALSINDEX.intValue(), "setVersion");
    mLuaState.pushJavaObject(configdynamicdatainfo);
    mLuaState.pushString(s);
    callLua(2, 0);
}
 
Example #20
Source File: LuaScriptInvoker.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private void initLuaContext(LuaState luaState){
	try {
		JavaFunction logfunction = new LogFunctionCallBack(luaState);
		logfunction.register("log");
		JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
		tostringfunction.register("tostring");
	} catch (LuaException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
 
Example #21
Source File: LuaScriptInvoker.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void invokeScript(String script){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoString(script);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	
	luaState.close();
}
 
Example #22
Source File: LuaScriptInvoker.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void invokeFileScript(String scriptFilePath){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoFile(scriptFilePath);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	luaState.close();
}
 
Example #23
Source File: LuaScriptInvoker.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public void invokeFileScript(String scriptFilePath){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoFile(scriptFilePath);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	luaState.close();
}
 
Example #24
Source File: LuaScriptInvoker.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public void invokeScript(String script){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoString(script);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	
	luaState.close();
}
 
Example #25
Source File: LuaScriptInvoker.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private void initLuaContext(LuaState luaState){
	try {
		JavaFunction logfunction = new LogFunctionCallBack(luaState);
		logfunction.register("log");
		JavaFunction tostringfunction = new ToStringFunctionCallBack(luaState);
		tostringfunction.register("tostring");
	} catch (LuaException e) {
		e.printStackTrace();
	}
	
}
 
Example #26
Source File: LuaScriptInvoker.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public void invokeFileScript(String scriptFilePath){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoFile(scriptFilePath);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	luaState.close();
}
 
Example #27
Source File: LuaScriptInvoker.java    From AppTroy with Apache License 2.0 5 votes vote down vote up
public void invokeFileScript(String scriptFilePath){
    LuaState luaState = LuaStateFactory.newLuaState();
    luaState.openLibs();
    this.initLuaContext(luaState);
    int error = luaState.LdoFile(scriptFilePath);
    if(error!=0){
        Logger.log("Read/Parse lua error. Exit");
        return;
    }
    luaState.close();
}
 
Example #28
Source File: LuaScriptInvoker.java    From AppTroy with Apache License 2.0 5 votes vote down vote up
public void invokeScript(String script){
    LuaState luaState = LuaStateFactory.newLuaState();
    luaState.openLibs();
    this.initLuaContext(luaState);
    int error = luaState.LdoString(script);
    if(error!=0){
        Logger.log("Read/Parse lua error. Exit");
        return;
    }

    luaState.close();
}
 
Example #29
Source File: LuaScriptInvoker.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public void invokeFileScript(String scriptFilePath){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoFile(scriptFilePath);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	luaState.close();
}
 
Example #30
Source File: LuaScriptInvoker.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public void invokeScript(String script){
	LuaState luaState = LuaStateFactory.newLuaState();
	luaState.openLibs();
	this.initLuaContext(luaState);
	int error = luaState.LdoString(script);
	if(error!=0){
		Logger.log("Read/Parse lua error. Exit");
		return;
	}
	
	luaState.close();
}