forked from apache/incubator-weex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#3081 from YorkShen/release/20190925
Merge Release/20190925 into master
- Loading branch information
Showing
65 changed files
with
1,860 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
android/sdk/src/main/java/org/apache/weex/jsEngine/CallBackCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.weex.jsEngine; | ||
|
||
public class CallBackCode { | ||
|
||
public static final CallBackCode ERROR_JSENGINE_CRASHED = new CallBackCode(-1, "js engine Crashed"); | ||
public static final CallBackCode JSENGINE_INIT_FINISH = new CallBackCode(1, "js Engine init finished"); | ||
public int code; | ||
public String msg; | ||
|
||
private CallBackCode(int code, String msg) { | ||
this.code = code; | ||
this.msg = msg; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
android/sdk/src/main/java/org/apache/weex/jsEngine/EnvCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.weex.jsEngine; | ||
|
||
public interface EnvCallback { | ||
void error(CallBackCode code); | ||
} |
29 changes: 29 additions & 0 deletions
29
android/sdk/src/main/java/org/apache/weex/jsEngine/JSBiz.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.weex.jsEngine; | ||
|
||
public class JSBiz { | ||
private String bizName; | ||
private String bizId; | ||
|
||
public JSBiz(String id, String name) { | ||
this.bizId = id; | ||
this.bizName = name; | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
android/sdk/src/main/java/org/apache/weex/jsEngine/JSContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.weex.jsEngine; | ||
|
||
import org.apache.weex.base.CalledByNative; | ||
import org.apache.weex.bridge.WXBridgeManager; | ||
import org.apache.weex.utils.WXLogUtils; | ||
|
||
import java.io.Serializable; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import static org.apache.weex.jsEngine.JSEngine.mCreatedJSContext; | ||
|
||
public class JSContext implements Serializable { | ||
private ConcurrentHashMap<String, JSFunction> funcMap = new ConcurrentHashMap<>(); | ||
//JSEnginePtrContainer | ||
private long mNativeContextPtr = 0; | ||
|
||
private JSException mExceptionTransfer = null; | ||
|
||
protected JSContext() { | ||
WXBridgeManager.getInstance().post(new Runnable() { | ||
@Override | ||
public void run() { | ||
mNativeContextPtr = nativeCreateContext(); | ||
mCreatedJSContext.put(mNativeContextPtr, JSContext.this); | ||
} | ||
}); | ||
} | ||
|
||
public void registerException(JSException e) { | ||
mExceptionTransfer = e; | ||
} | ||
|
||
public void destroy() { | ||
mCreatedJSContext.remove(mNativeContextPtr); | ||
mExceptionTransfer = null; | ||
WXBridgeManager.getInstance().post(new Runnable() { | ||
@Override | ||
public void run() { | ||
if (mNativeContextPtr != 0) { | ||
long tmp = mNativeContextPtr; | ||
mNativeContextPtr = 0; | ||
nativeDestroyContext(tmp); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public void bindFunction(final String name, final JSFunction function) { | ||
WXBridgeManager.getInstance().post(new Runnable() { | ||
@Override | ||
public void run() { | ||
funcMap.put(name, function); | ||
nativeBindFunc(mNativeContextPtr, name); | ||
} | ||
}); | ||
} | ||
|
||
public void unBindFunction(final String name) { | ||
WXBridgeManager.getInstance().post(new Runnable() { | ||
@Override | ||
public void run() { | ||
funcMap.remove(name); | ||
nativeUnBindFunc(mNativeContextPtr, name); | ||
} | ||
}); | ||
} | ||
|
||
public void Eval(final String script) { | ||
WXBridgeManager.getInstance().post(new Runnable() { | ||
@Override | ||
public void run() { | ||
nativeExecJS(mNativeContextPtr, script); | ||
} | ||
}); | ||
} | ||
|
||
|
||
@CalledByNative | ||
public String Invoke(String name, String args) { | ||
JSFunction jsFunction = funcMap.get(name); | ||
if (jsFunction != null) { | ||
WXLogUtils.d("jsEngine invoke " + name + " arg:" + args); | ||
return jsFunction.invoke(args); | ||
} | ||
return ""; | ||
} | ||
|
||
@CalledByNative | ||
public void Exception(String exception) { | ||
if (exception != null && mExceptionTransfer != null) { | ||
this.mExceptionTransfer.exception(exception); | ||
} | ||
} | ||
|
||
private native long nativeCreateContext(); | ||
|
||
private native void nativeDestroyContext(long ctxPtr); | ||
|
||
private native void nativeBindFunc(long ctxPtr, String name); | ||
|
||
private native void nativeUnBindFunc(long ctxPtr, String name); | ||
|
||
private native void nativeExecJS(long ctxPtr, String script); | ||
} |
Oops, something went wrong.