Skip to content

Commit 44fe2d0

Browse files
committed
1、优化Android的模块与面向对象模块功能,让其行为与在iOS上一致。
2、修复iOS上LuaValue如果为Object类型时,可能丢失Object引用问题而产生崩溃。
1 parent 6ed473a commit 44fe2d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1958
-1219
lines changed

Sample/Android/app/src/main/java/cn/vimfung/luascriptcore/sample/LogModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static String version()
1515
return "1.0.0";
1616
}
1717

18-
public void writeLog(String message)
18+
public static void writeLog(String message)
1919
{
2020
Log.v("luascriptcore", message);
2121
}

Sample/Android/app/src/main/java/cn/vimfung/luascriptcore/sample/MainActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.HashMap;
2222

2323
import cn.vimfung.luascriptcore.LuaContext;
24+
import cn.vimfung.luascriptcore.LuaFunction;
2425
import cn.vimfung.luascriptcore.LuaMethodHandler;
2526
import cn.vimfung.luascriptcore.LuaValue;
2627
import cn.vimfung.luascriptcore.modules.oo.LuaObjectClass;
@@ -128,6 +129,7 @@ public LuaValue onExecute(LuaValue[] arguments) {
128129
devInfoMap.put("systemVersion", Build.VERSION.RELEASE);
129130

130131
return new LuaValue(devInfoMap);
132+
131133
}
132134
});
133135

@@ -193,7 +195,7 @@ public void onClick(View v) {
193195
_luaContext.registerModule(Person.class);
194196
}
195197

196-
_luaContext.evalScript("local person = Person:create(); person:setName('vimfung'); person:speak(); person:walk();");
198+
_luaContext.evalScript("local person = Person.create(); person:setName('vimfung'); print(person:name()); person:speak(); person:walk();");
197199

198200
}
199201
});

Sample/Android/app/src/main/java/cn/vimfung/luascriptcore/sample/Person.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.util.Log;
44

5+
import cn.vimfung.luascriptcore.LuaContext;
56
import cn.vimfung.luascriptcore.modules.oo.LuaObjectClass;
67

78
/**
@@ -21,4 +22,9 @@ public void walk()
2122
{
2223
Log.v("luascriptcore", String.format("%s walk", name));
2324
}
25+
26+
public Person(LuaContext context)
27+
{
28+
super(context);
29+
};
2430
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
636 Bytes
Binary file not shown.
-3.48 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)