Skip to content

Commit

Permalink
定版2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vimfung committed Aug 8, 2018
1 parent cb43ed8 commit 3417019
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 59 deletions.
2 changes: 1 addition & 1 deletion LuaScriptCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "LuaScriptCore"
s.version = "2.2.1"
s.version = "2.3.0"
s.summary = "An easy-to-use OC-Lua bridge"

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 0 additions & 2 deletions Sample/Android/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cn.vimfung.luascriptcore.sample;

import android.util.Log;

public class ErrLogModule extends LogModule
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.util.Log;

import cn.vimfung.luascriptcore.LuaExclude;
import cn.vimfung.luascriptcore.LuaExportType;
import cn.vimfung.luascriptcore.LuaTuple;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -68,60 +69,78 @@ public void onException(String message) {
@Override
public void onClick(View v) {

LuaValue retValue = _luaContext.evalScript("print(10);return 'Hello World';");
Log.v("lsc", retValue.toString());

//List Native -> Lua
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("hahahahahah");
arrayList.add("Hello World");
LuaValue value = new LuaValue(arrayList);

_luaContext.evalScript("function printArray (arr) print('--------', #arr); for i,v in ipairs(arr) do print(v); end end");

LuaValue[] args = new LuaValue[] {value};
_luaContext.callMethod("printArray", args);

//List Lua -> Native
LuaValue arrValue = _luaContext.evalScript("return {1, 'Hello World'};");
Log.v("lsc", arrValue.toString());
ArrayList arrayList1 = arrValue.toArrayList();
for (Object obj : arrayList1)
{
Log.v("LTN ArrayList", obj.toString());
}
List<?> list = arrValue.toList();
for (Object obj : list)
{
Log.v("LTN List", obj.toString());
}

// LuaValue retValue = _luaContext.evalScript("print(10);return 'Hello World';");
// Log.v("lsc", retValue.toString());
//
// //List Native -> Lua
// ArrayList<String> arrayList = new ArrayList<String>();
// arrayList.add("hahahahahah");
// arrayList.add("Hello World");
// LuaValue value = new LuaValue(arrayList);
//
// _luaContext.evalScript("function printArray (arr) print('--------', #arr); for i,v in ipairs(arr) do print(v); end end");
//
// LuaValue[] args = new LuaValue[] {value};
// _luaContext.callMethod("printArray", args);
//
// //List Lua -> Native
// LuaValue arrValue = _luaContext.evalScript("return {1, 'Hello World'};");
// Log.v("lsc", arrValue.toString());
// ArrayList arrayList1 = arrValue.toArrayList();
// for (Object obj : arrayList1)
// {
// Log.v("LTN ArrayList", obj.toString());
// }
// List<?> list = arrValue.toList();
// for (Object obj : list)
// {
// Log.v("LTN List", obj.toString());
// }
//
//Map Native -> Lua
HashMap<String, String> map = new HashMap<>();
map.put("Hello", "World");
map.put("aaa", "bbb");
map.put("ccc", null);
LuaValue mapValue = new LuaValue(map);

_luaContext.evalScript("function printMap (map) print('--------', #map); for k,v in pairs(map) do print(k, v); end end");

LuaValue[] mapArgs = new LuaValue[] {mapValue};
_luaContext.callMethod("printMap", mapArgs);

//Map Lua -> Native
LuaValue mapRetValue = _luaContext.evalScript("return {aaa=1, bbb='Hello World'};");
Log.v("lsc", mapRetValue.toString());
HashMap hashMap = mapRetValue.toHashMap();
for (Object obj : hashMap.keySet())
{
Log.v("LTN HashMap", hashMap.get(obj).toString());
}

Map<?, ?> map2 = mapRetValue.toMap();
for (Object obj : map2.keySet())
{
Log.v("LTN Map", map2.get(obj).toString());
}

// LuaValue[] mapArgs = new LuaValue[] {mapValue};
// _luaContext.callMethod("printMap", mapArgs);
//
// //Map Lua -> Native
// LuaValue mapRetValue = _luaContext.evalScript("return {aaa=1, bbb='Hello World'};");
// Log.v("lsc", mapRetValue.toString());
// HashMap hashMap = mapRetValue.toHashMap();
// for (Object obj : hashMap.keySet())
// {
// Log.v("LTN HashMap", hashMap.get(obj).toString());
// }
//
// Map<?, ?> map2 = mapRetValue.toMap();
// for (Object obj : map2.keySet())
// {
// Log.v("LTN Map", map2.get(obj).toString());
// }

// ArrayList<HashMap<String, String>> testList = new ArrayList<>();
//
// HashMap<String, String> m1 = new HashMap<>();
// m1.put("aaa", "bbb");
// m1.put("ccc", "dddd");
// testList.add(m1);
//
// HashMap<String, String> m2 = new HashMap<>();
// m2.put("eee", "ffff");
// m2.put("ggg", "hhh");
// testList.add(m2);
//
// LuaValue testValue = new LuaValue(testList);
// _luaContext.evalScript("function printArray (arr) print('--------', #arr); for i,v in ipairs(arr) do print('------ elm = ', v); for m,n in pairs(v) do print(m, n); end end end");
//
// LuaValue[] args = new LuaValue[] {testValue};
// _luaContext.callMethod("printArray", args);

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class NativeData implements LuaExportType
{
public String dataId;

private HashMap<String, String> _data = new HashMap<String, String>();

public static Person createPerson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.HashMap;

import cn.vimfung.luascriptcore.LuaContext;
import cn.vimfung.luascriptcore.LuaExclude;
import cn.vimfung.luascriptcore.LuaExportType;
import cn.vimfung.luascriptcore.LuaExportTypeConfig;
import cn.vimfung.luascriptcore.LuaFunction;
Expand All @@ -20,11 +21,14 @@
public class Person implements LuaExportType
{
public String name;

@LuaExclude
public void speak()
{
Log.v("luascriptcore", String.format("%s speak", name));
}

@LuaExclude
public void walk()
{
Log.v("luascriptcore", String.format("%s walk", name));
Expand Down
4 changes: 2 additions & 2 deletions Source/Android/luascriptcore/compile-5.1.5.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 14
targetSdkVersion 24
versionCode 20200
versionName "2.2.0"
versionName "2.3.0"

ndk {
moduleName "LuaScriptCore"
Expand Down Expand Up @@ -87,7 +87,7 @@ ext {
siteUrl = 'https://github.com/vimfung/LuaScriptCore'
gitUrl = 'https://github.com/vimfung/LuaScriptCore.git'

libraryVersion = '2.2.1'
libraryVersion = '2.3.0'

developerId = 'vimfung'
developerName = 'Vim Fung'
Expand Down
4 changes: 2 additions & 2 deletions Source/Android/luascriptcore/compile.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 14
targetSdkVersion 24
versionCode 20200
versionName "2.2.0"
versionName "2.3.0"

ndk {
moduleName "LuaScriptCore"
Expand Down Expand Up @@ -96,7 +96,7 @@ ext {
siteUrl = 'https://github.com/vimfung/LuaScriptCore'
gitUrl = 'https://github.com/vimfung/LuaScriptCore.git'

libraryVersion = '2.2.1'
libraryVersion = '2.3.0'

developerId = 'vimfung'
developerName = 'Vim Fung'
Expand Down
2 changes: 1 addition & 1 deletion Source/Android/luascriptcore/src/main/jni/Android-5.1.5.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

APP_PLATFORM := android-14

LOCAL_MODULE := LuaScriptCore
LOCAL_LDFLAGS := -Wl,--build-id
LOCAL_LDLIBS := \
Expand Down Expand Up @@ -70,6 +69,7 @@ LOCAL_SRC_FILES := \
../../../../../lua-common/LuaExportsTypeManager.cpp \
../../../../../lua-common/LuaExportTypeDescriptor.cpp \
../../../../../lua-common/LuaExportPropertyDescriptor.cpp \
../../../../../lua-common/LuaOperationQueue.cpp \

LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../../../lua-core-5.1.5/src
Expand Down
3 changes: 2 additions & 1 deletion Source/Unity3D/UnityProject/Assets/Scripts/LogModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

public class LogModule : LuaExportType
{
[LuaExclude]
public static void writeLog(String message)
{
Debug.LogFormat ("string log = {0}", message);
}

public static void writeLog(int value)
{
Debug.LogFormat ("int log = {0}", value);
Expand Down
1 change: 1 addition & 0 deletions Source/Unity3D/UnityProject/Assets/Scripts/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public class Person : LuaExportType
{
private string _name;

public string name
{
get
Expand Down
2 changes: 1 addition & 1 deletion Source/Unity3D/UnityProject/Assets/Scripts/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void registerModuleButtonClickedHandler()
/// </summary>
public void registerClassButtonClickedHandler()
{
LuaContext.currentContext.evalScript ("local p = Person:createPersonError(); print(p);");
// LuaContext.currentContext.evalScript ("local p = Person:createPersonError(); print(p);");
LuaContext.currentContext.evalScript ("print(Chinese); function Person.prototype:init() print('Person create'); end; local p = Person:createPerson(); print(p); p.name='xxxx'; p:speak(); p.intValue = 111; print('intValue', p.intValue); print(Person:printPerson(p));");
}

Expand Down
10 changes: 10 additions & 0 deletions Source/Unity3D/iOS_OSX/LuaScriptCore_5_1.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
7C8499FA1F0CE2FD006A99A2 /* LuaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8499F81F0CE2FD006A99A2 /* LuaSession.cpp */; };
7C8499FB1F0CE2FD006A99A2 /* LuaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8499F81F0CE2FD006A99A2 /* LuaSession.cpp */; };
7C8499FC1F0CE2FD006A99A2 /* LuaSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C8499F91F0CE2FD006A99A2 /* LuaSession.h */; };
7C84E168211A7DE100147C46 /* LuaOperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C84E166211A7DE100147C46 /* LuaOperationQueue.cpp */; };
7C84E169211A7DE100147C46 /* LuaOperationQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C84E166211A7DE100147C46 /* LuaOperationQueue.cpp */; };
7C84E16A211A7DE100147C46 /* LuaOperationQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C84E167211A7DE100147C46 /* LuaOperationQueue.h */; };
7C98BB4D1FD1357E00A47296 /* LuaUnityExportMethodDescriptor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7C98BB471FD1357D00A47296 /* LuaUnityExportMethodDescriptor.hpp */; };
7C98BB4E1FD1357E00A47296 /* LuaUnityExportMethodDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C98BB481FD1357D00A47296 /* LuaUnityExportMethodDescriptor.cpp */; };
7C98BB4F1FD1357E00A47296 /* LuaUnityExportMethodDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C98BB481FD1357D00A47296 /* LuaUnityExportMethodDescriptor.cpp */; };
Expand Down Expand Up @@ -273,6 +276,8 @@
7C7001601FEBC45500168D09 /* LuaTmpValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaTmpValue.cpp; sourceTree = "<group>"; };
7C8499F81F0CE2FD006A99A2 /* LuaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaSession.cpp; sourceTree = "<group>"; };
7C8499F91F0CE2FD006A99A2 /* LuaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaSession.h; sourceTree = "<group>"; };
7C84E166211A7DE100147C46 /* LuaOperationQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaOperationQueue.cpp; sourceTree = "<group>"; };
7C84E167211A7DE100147C46 /* LuaOperationQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaOperationQueue.h; sourceTree = "<group>"; };
7C98BB471FD1357D00A47296 /* LuaUnityExportMethodDescriptor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LuaUnityExportMethodDescriptor.hpp; sourceTree = "<group>"; };
7C98BB481FD1357D00A47296 /* LuaUnityExportMethodDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaUnityExportMethodDescriptor.cpp; sourceTree = "<group>"; };
7C98BB491FD1357D00A47296 /* LuaUnityExportPropertyDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaUnityExportPropertyDescriptor.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -447,6 +452,8 @@
7CBA49851DD5986800D5880A /* lua-common */ = {
isa = PBXGroup;
children = (
7C84E166211A7DE100147C46 /* LuaOperationQueue.cpp */,
7C84E167211A7DE100147C46 /* LuaOperationQueue.h */,
7C7001601FEBC45500168D09 /* LuaTmpValue.cpp */,
7C70015F1FEBC45500168D09 /* LuaTmpValue.hpp */,
7C8499F81F0CE2FD006A99A2 /* LuaSession.cpp */,
Expand Down Expand Up @@ -652,6 +659,7 @@
7CDC7E041DDAD7D2002F82C9 /* LuaObjectEncoder.hpp in Headers */,
7C98BB611FD135D600A47296 /* LuaExportTypeDescriptor.hpp in Headers */,
7CF298731F5E72790090AFC5 /* llex.h in Headers */,
7C84E16A211A7DE100147C46 /* LuaOperationQueue.h in Headers */,
7C5318DB1ECBF42E00E0EB17 /* LuaManagedObject.h in Headers */,
7C60A9F41DD95110000D56CA /* LuaContext.h in Headers */,
7C98BB521FD1357E00A47296 /* LuaUnityExportPropertyDescriptor.hpp in Headers */,
Expand Down Expand Up @@ -854,6 +862,7 @@
7C1CB4381DDD67310087B092 /* LuaObjectDecoder.cpp in Sources */,
7C98BB631FD135D600A47296 /* LuaExportPropertyDescriptor.cpp in Sources */,
7C60A9F21DD95106000D56CA /* LuaPointer.cpp in Sources */,
7C84E168211A7DE100147C46 /* LuaOperationQueue.cpp in Sources */,
7CF2986D1F5E72790090AFC5 /* linit.c in Sources */,
7CF2986A1F5E72790090AFC5 /* lgc.c in Sources */,
7C60A9F01DD95106000D56CA /* LuaObjectDescriptor.cpp in Sources */,
Expand Down Expand Up @@ -921,6 +930,7 @@
7C2291C01E35A54300855915 /* LuaUnityEnv.cpp in Sources */,
7C98BB641FD135D600A47296 /* LuaExportPropertyDescriptor.cpp in Sources */,
7CF2986E1F5E72790090AFC5 /* linit.c in Sources */,
7C84E169211A7DE100147C46 /* LuaOperationQueue.cpp in Sources */,
7CF2986B1F5E72790090AFC5 /* lgc.c in Sources */,
7C5318D51ECBF30B00E0EB17 /* LuaDataExchanger.cpp in Sources */,
7CF2988E1F5E72790090AFC5 /* lstrlib.c in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Source/iOS_OSX/Code/LuaScriptCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2016年 vimfung. All rights reserved.
//

#define LuaScriptCoreVersion @"2.2.1"
#define LuaScriptCoreVersion @"2.3.0"

#import "LSCContext.h"
#import "LSCValue.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/iOS_OSX/LuaScriptCore-OSX-Swift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.1</string>
<string>2.3.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion Source/iOS_OSX/LuaScriptCore-iOS-Swift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.2.1</string>
<string>2.3.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 3417019

Please sign in to comment.