Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3946 from ayeung/timob-12185

TIMOB-12185: Remove Rhino as a supported runtime
  • Loading branch information...
commit 12bff9f1a573e7edf41d54e50b407aeb691b6286 2 parents a71ef13 + 7323961
@joshthecoder joshthecoder authored
Showing with 143 additions and 5,095 deletions.
  1. +3 −92 android/build/common.xml
  2. +0 −1  android/dependency.json
  3. +2 −2 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/Kroll.java
  4. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/JSONUtils.java
  5. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollAPIUpdater.java
  6. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollAnnotationUtils.java
  7. +21 −101 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollBindingGenerator.java
  8. +0 −92 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollGeneratedBindingsRhino.java.fm
  9. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollJSONGenerator.java
  10. +0 −15 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollModuleBindingsRhino.java.fm
  11. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollVisitor.java
  12. +1 −180 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBinding.fm
  13. +0 −514 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBindingRhino.java.fm
  14. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBindingV8.cpp.fm
  15. +1 −1  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBindingV8.h.fm
  16. +2 −2 android/runtime/common/src/java/org/appcelerator/kroll/KrollRuntime.java
  17. +1 −1  android/runtime/common/src/js/console.js
  18. +1 −1  android/runtime/common/src/js/invoker.js
  19. +7 −12 android/runtime/common/src/js/kroll.js
  20. +30 −71 android/runtime/common/src/js/module.js
  21. +15 −31 android/runtime/common/src/js/titanium.js
  22. +1 −1  android/runtime/common/src/js/url.js
  23. +0 −12 android/runtime/rhino/.classpath
  24. +0 −2  android/runtime/rhino/.gitignore
  25. +0 −33 android/runtime/rhino/.project
  26. +0 −11 android/runtime/rhino/AndroidManifest.xml
  27. +0 −209 android/runtime/rhino/build.xml
  28. BIN  android/runtime/rhino/lib/js.jar
  29. +0 −40 android/runtime/rhino/proguard.cfg
  30. +0 −13 android/runtime/rhino/project.properties
  31. +0 −4 android/runtime/rhino/res/values/strings.xml
  32. +0 −19 android/runtime/rhino/src/bindings/KrollGeneratedBindings.java
  33. +0 −146 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/EventEmitter.java
  34. +0 −90 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/GlobalSandbox.java
  35. +0 −296 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/KrollBindings.java
  36. +0 −37 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/KrollDate.java
  37. +0 −276 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/KrollGlobal.java
  38. +0 −159 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/KrollScriptRunner.java
  39. +0 −200 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/KrollScriptableDict.java
  40. +0 −169 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/KrollWith.java
  41. +0 −505 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/Proxy.java
  42. +0 −98 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/ProxyFactory.java
  43. +0 −141 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/RhinoFunction.java
  44. +0 −148 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/RhinoObject.java
  45. +0 −208 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/RhinoRuntime.java
  46. +0 −24 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/RhinoUtil.java
  47. +0 −546 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/TypeConverter.java
  48. +0 −154 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/modules/AssetsModule.java
  49. +0 −191 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/modules/ScriptsModule.java
  50. +0 −41 android/runtime/rhino/src/js/rhino.js
  51. +2 −3 android/runtime/v8/tools/genBootstrap.py
  52. +1 −27 android/titanium/src/java/org/appcelerator/titanium/util/TiPlatformHelper.java
  53. +1 −8 android/titanium/src/java/ti/modules/titanium/TitaniumModule.java
  54. +1 −5 site_scons/package.py
  55. +2 −10 support/android/android.py
  56. +5 −12 support/android/builder.py
  57. +1 −4 support/android/compiler.py
  58. +0 −30 support/android/templates/App.java
  59. +23 −34 support/module/android/bootstrap.py
  60. +5 −50 support/module/android/build.xml
  61. +5 −8 support/module/android/templates/src/___MODULE_ID_AS_FOLDER___/ExampleProxy.java
  62. +6 −9 support/module/android/templates/src/___MODULE_ID_AS_FOLDER___/___MODULE_NAME_CAMEL___Module.java
View
95 android/build/common.xml
@@ -1,7 +1,7 @@
<!--
Appcelerator Titanium Mobile
-Copyright (c) 2010-2012 by Appcelerator, Inc. All Rights Reserved.
+Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
Licensed under the terms of the Apache Public License
Please see the LICENSE included with this distribution for details.
@@ -35,7 +35,6 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<property name="kroll.apt.project.dir" location="${ti.android.root}/kroll-apt"/>
<property name="kroll.common.project.dir" location="${ti.android.root}/runtime/common"/>
<property name="kroll.v8.project.dir" location="${ti.android.root}/runtime/v8"/>
- <property name="kroll.rhino.project.dir" location="${ti.android.root}/runtime/rhino"/>
<property name="kroll.runtime" value="all"/>
<condition property="ndk.build" value="${kroll.v8.project.dir}/ndk-build.cmd" else="${kroll.v8.project.dir}/ndk-build.sh">
@@ -141,10 +140,6 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<pathelement path="${dist.classes.dir}/kroll-v8"/>
</path>
- <path id="kroll.rhino.path">
- <pathelement path="${dist.classes.dir}/kroll-rhino"/>
- </path>
-
<path id="titanium.path">
<pathelement path="${dist.classes.dir}/titanium"/>
<fileset dir="${titanium.project.dir}/lib" includes="**/*.jar"/>
@@ -358,32 +353,24 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
</macrodef>
<macrodef name="generate.bindings">
- <attribute name="runtime"/>
<attribute name="dest"/>
<sequential>
<apply executable="java" parallel="true" failonerror="true">
<arg value="-classpath"/>
<arg value="${toString:kroll.apt.path}"/>
<arg value="org.appcelerator.kroll.annotations.generator.KrollBindingGenerator"/>
- <arg value="@{runtime}"/>
<arg file="@{dest}"/>
<!-- isModule -->
<arg value="false"/>
<!-- moduleId (Titanium for platform) -->
<arg value="titanium"/>
- <!-- bindingsClassName (empty for platform) -->
- <arg value=" "/>
<fileset dir="${dist.json.dir}" includes="**/*.json"/>
</apply>
</sequential>
</macrodef>
<target name="generate.kroll.v8.bindings" depends="build.kroll.apt">
- <generate.bindings runtime="v8" dest="${kroll.v8.project.dir}/generated"/>
- </target>
-
- <target name="generate.kroll.rhino.bindings" depends="build.kroll.apt">
- <generate.bindings runtime="rhino" dest="${kroll.rhino.project.dir}/generated"/>
+ <generate.bindings dest="${kroll.v8.project.dir}/generated"/>
</target>
<target name="build.kroll.v8.so" depends="generate.kroll.v8.bindings">
@@ -415,77 +402,6 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<jar destfile="${kroll.common.dest}" basedir="${kroll.common.classes.dir}"/>
</target>
- <import file="${kroll.rhino.project.dir}/build.xml"/>
- <macrodef name="compile.kroll.rhino.bindings">
- <sequential>
- <javac destdir="${kroll.rhino.gen.classes.dir}"
- debug="true" target="1.6" source="1.6"
- includeantruntime="false">
- <classpath refid="android"/>
- <classpath refid="rhino"/>
- <classpath>
- <fileset file="${dist.dir}/kroll-common.jar"/>
- <dirset dir="${kroll.rhino.classes.dir}"/>
- <fileset dir="${dist.dir}" includes="titanium-*.jar"/>
- </classpath>
- <classpath refid="titanium.path"/>
- <classpath refid="kroll.apt.path"/>
-
- <src path="${kroll.rhino.project.dir}/generated"/>
- </javac>
- </sequential>
- </macrodef>
-
- <target name="build.kroll.rhino.jar" depends="build.kroll.common.jar,generate.kroll.rhino.bindings,compile.kroll.rhino.js,generate.kroll.rhino.idswitch">
- <property name="kroll.rhino.classes.dir" location="${dist.classes.dir}/kroll-rhino"/>
- <property name="kroll.rhino.gen.classes.dir" location="${dist.classes.dir}/kroll-rhino-gen"/>
- <property name="kroll.rhino.dest" value="${dist.dir}/kroll-rhino.jar"/>
- <property name="kroll.rhino.bindings.dest" value="${dist.dir}/kroll-rhino-bindings.jar"/>
-
- <mkdir dir="${kroll.rhino.classes.dir}"/>
- <mkdir dir="${kroll.rhino.gen.classes.dir}"/>
-
- <javac destdir="${kroll.rhino.classes.dir}" debug="true"
- target="1.6" source="1.6" includeantruntime="false">
- <classpath refid="android"/>
- <classpath refid="rhino"/>
- <classpath>
- <fileset file="${dist.dir}/kroll-common.jar"/>
- </classpath>
- <classpath refid="kroll.rhino.js"/>
- <classpath refid="titanium.path"/>
- <classpath refid="kroll.apt.path"/>
- <classpath>
- <fileset dir="${dist.dir}" includes="titanium-*.jar"/>
- <fileset file="${kroll.rhino.bindings.dest}"/>
- </classpath>
-
- <src path="${kroll.rhino.project.dir}/src/java"/>
- <src path="${kroll.rhino.project.dir}/src/bindings"/>
- </javac>
-
- <!-- use the actual generated bindings -->
- <delete>
- <fileset dir="${kroll.rhino.classes.dir}" includes="**/KrollGeneratedBindings.class"/>
- </delete>
-
-
- <compile.kroll.rhino.bindings/>
-
- <antcall target="generate.kroll.rhino.serials"/>
- <compile.kroll.rhino.bindings/>
-
- <jar destfile="${kroll.rhino.bindings.dest}" basedir="${kroll.rhino.gen.classes.dir}"/>
-
- <jar destfile="${kroll.rhino.dest}">
- <fileset dir="${kroll.rhino.classes.dir}" includes="**/*"/>
- <fileset dir="${kroll.rhino.gen.classes.dir}" includes="**/*"/>
- <fileset dir="${kroll.rhino.project.dir}/jsbin" includes="**/*"/>
- </jar>
- </target>
-
- <target name="build.kroll.runtime.rhino" depends="build.kroll.rhino.jar"/>
-
<target name="build.kroll.v8.jar" depends="build.kroll.common.jar">
<property name="kroll.v8.classes.dir" location="${dist.classes.dir}/kroll-v8"/>
<mkdir dir="${kroll.v8.classes.dir}"/>
@@ -504,7 +420,7 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<target name="build.kroll.runtime.v8" depends="build.kroll.v8.jar,build.kroll.v8.so"/>
<target name="build.kroll.runtime.all"
- depends="build.kroll.runtime.rhino,build.kroll.runtime.v8"/>
+ depends="build.kroll.runtime.v8"/>
<target name="build.titanium" depends="build.kroll.common.jar">
<property name="build.dir" value="${dist.classes.dir}/titanium"/>
@@ -687,11 +603,6 @@ Common ant tasks and macros for building Android-based Titanium modules and proj
<fileset dir="${dist.dir}" includes="**/*" excludes="libv8/**/*" defaultexcludes="false"/>
</delete>
- <!-- Clean up the generated rhino files -->
- <delete includeemptydirs="true" failonerror="false">
- <fileset dir="${kroll.rhino.project.dir}/generated" includes="**/*" defaultexcludes="false"/>
- </delete>
-
<!-- V8 clean target requires we have libv8 for now -->
<build.ti.ant.tasks/>
<define.ti.ant.tasks/>
View
1  android/dependency.json
@@ -32,7 +32,6 @@
"runtimes":
{
"v8":["kroll-v8.jar"],
- "rhino":["kroll-rhino.jar","js.jar"],
"defaultRuntime":"v8"
}
}
View
4 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/Kroll.java
@@ -1,7 +1,7 @@
package org.appcelerator.kroll.annotations;
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2010-2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
@@ -328,7 +328,7 @@
/**
* Declares a Kroll proxy.<br>
- * <p>Proxies are the API interface between Javascript (Rhino) and Java.
+ * <p>Proxies are the API interface between Javascript and Java.
* Proxy classes must use this or {@link module the module annotation} to expose methods and properties,
* and must follow a few specific source patterns:
* <ul>
View
2  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/JSONUtils.java
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2010 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
2  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollAPIUpdater.java
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
2  ...kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollAnnotationUtils.java
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2010-2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
122 ...roll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollBindingGenerator.java
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2010-2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
@@ -16,7 +16,6 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.security.CodeSource;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -33,16 +32,11 @@
public class KrollBindingGenerator
{
- private static final String RUNTIME_V8 = "v8";
- private static final String RUNTIME_RHINO = "rhino";
private static final String Kroll_DEFAULT = "org.appcelerator.kroll.annotations.Kroll.DEFAULT";
- private String runtime, outPath, moduleId, bindingsClassName;
- private boolean isModule;
+ private String outPath, moduleId;
private Configuration fmConfig;
private Template v8SourceTemplate, v8HeaderTemplate;
- private Template rhinoSourceTemplate, rhinoGeneratedBindingsTemplate, rhinoModuleBindingsTemplate;
- private ArrayList<HashMap<String, String>> rhinoBindings = new ArrayList<HashMap<String, String>>();
private HashMap<String, Object> apiTree = new HashMap<String, Object>();
private HashMap<String, Object> proxies = new HashMap<String, Object>();
private HashMap<String, Object> modules = new HashMap<String, Object>();
@@ -53,13 +47,10 @@
private JSONUtils jsonUtils;
- public KrollBindingGenerator(String runtime, String outPath, boolean isModule, String moduleId, String bindingsClassName)
+ public KrollBindingGenerator(String outPath, String moduleId)
{
- this.runtime = runtime;
this.outPath = outPath;
- this.isModule = isModule;
this.moduleId = moduleId;
- this.bindingsClassName = bindingsClassName;
this.jsonUtils = new JSONUtils();
@@ -76,40 +67,13 @@ protected void initTemplates()
ClassLoader loader = getClass().getClassLoader();
String templatePackage = "org/appcelerator/kroll/annotations/generator/";
- if (RUNTIME_V8.equals(runtime)) {
- InputStream v8HeaderStream = loader.getResourceAsStream(templatePackage + "ProxyBindingV8.h.fm");
- InputStream v8SourceStream = loader.getResourceAsStream(templatePackage + "ProxyBindingV8.cpp.fm");
-
- v8HeaderTemplate = new Template(
- "ProxyBindingV8.h.fm",
- new InputStreamReader(v8HeaderStream),
- fmConfig);
-
- v8SourceTemplate = new Template(
- "ProxyBindingV8.cpp.fm",
- new InputStreamReader(v8SourceStream),
- fmConfig);
-
- } else if (RUNTIME_RHINO.equals(runtime)) {
- InputStream rhinoSourceStream = loader.getResourceAsStream(templatePackage + "ProxyBindingRhino.java.fm");
- InputStream rhinoGeneratedBindingsStream = loader.getResourceAsStream(templatePackage + "KrollGeneratedBindingsRhino.java.fm");
- InputStream rhinoModuleBindingsStream = loader.getResourceAsStream(templatePackage + "KrollModuleBindingsRhino.java.fm");
-
- rhinoSourceTemplate = new Template(
- "ProxyBindingRhino.java.fm",
- new InputStreamReader(rhinoSourceStream),
- fmConfig);
-
- rhinoGeneratedBindingsTemplate = new Template(
- "KrollGeneratedBindingsRhino.java.fm",
- new InputStreamReader(rhinoGeneratedBindingsStream),
- fmConfig);
-
- rhinoModuleBindingsTemplate = new Template(
- "KrollModuleBindingsRhino.java.fm",
- new InputStreamReader(rhinoModuleBindingsStream),
- fmConfig);
- }
+ InputStream v8HeaderStream = loader.getResourceAsStream(templatePackage + "ProxyBindingV8.h.fm");
+ InputStream v8SourceStream = loader.getResourceAsStream(templatePackage + "ProxyBindingV8.cpp.fm");
+
+ v8HeaderTemplate = new Template("ProxyBindingV8.h.fm", new InputStreamReader(v8HeaderStream), fmConfig);
+
+ v8SourceTemplate = new Template("ProxyBindingV8.cpp.fm", new InputStreamReader(v8SourceStream), fmConfig);
+
} catch (IOException e) {
e.printStackTrace();
}
@@ -318,72 +282,31 @@ protected void generateBindings()
root.put("tiProxies", tiProxies);
root.put("tiModules", tiModules);
- if (RUNTIME_V8.equals(runtime)) {
- String v8ProxyHeader = proxyName + ".h";
- String v8ProxySource = proxyName + ".cpp";
-
- saveTypeTemplate(v8HeaderTemplate, v8ProxyHeader, root);
- saveTypeTemplate(v8SourceTemplate, v8ProxySource, root);
-
- } else if (RUNTIME_RHINO.equals(runtime)) {
- root.put("apiTree", getProxyApiTree(proxy));
-
- String rhinoProxySource = proxyName.replace('.', File.separatorChar) + "Prototype.java";
- saveTypeTemplate(rhinoSourceTemplate, rhinoProxySource, root);
-
- HashMap<String, String> binding = new HashMap<String, String>();
- binding.put("class", proxyName);
-
- Map<String, Object> proxyAttrs = jsonUtils.getStringMap(proxy, "proxyAttrs");
- binding.put("apiName", (String) proxyAttrs.get("name"));
- rhinoBindings.add(binding);
- }
- }
- }
-
- protected void generateRhinoBindings()
- {
- HashMap<Object, Object> root = new HashMap<Object, Object>();
- root.put("bindings", rhinoBindings);
-
- if (isModule) {
- String path = moduleId.replaceAll(".", "/");
- root.put("packageName", moduleId);
- root.put("className", bindingsClassName);
+ String v8ProxyHeader = proxyName + ".h";
+ String v8ProxySource = proxyName + ".cpp";
- saveTypeTemplate(rhinoModuleBindingsTemplate, path + "/" + bindingsClassName + ".java", root);
+ saveTypeTemplate(v8HeaderTemplate, v8ProxyHeader, root);
+ saveTypeTemplate(v8SourceTemplate, v8ProxySource, root);
- } else {
- saveTypeTemplate(rhinoGeneratedBindingsTemplate,
- "org/appcelerator/kroll/runtime/rhino/KrollGeneratedBindings.java",
- root);
}
}
public static void main(String[] args)
throws Exception
{
- if (args.length < 6) {
- System.err.println("Usage: KrollBindingGenerator <runtime> <outdir> <isModule> <modulePackage> <moduleClassName> <binding.json> [<binding.json> ...]");
+ if (args.length < 4) {
+ System.err.println("Usage: KrollBindingGenerator <outdir> <isModule> <modulePackage> <binding.json> [<binding.json> ...]");
System.exit(1);
}
- String runtime = args[0];
+ String outDir = args[0];
+ boolean isModule = "true".equalsIgnoreCase(args[1]);
+ String packageName = args[2];
- if (!(RUNTIME_V8.equals(runtime) || RUNTIME_RHINO.equals(runtime))) {
- System.err.println("\"runtime\" must be v8 or rhino");
- System.exit(1);
- }
-
- String outDir = args[1];
- boolean isModule = "true".equalsIgnoreCase(args[2]);
- String packageName = args[3];
- String className = args[4];
-
- KrollBindingGenerator generator = new KrollBindingGenerator(runtime, outDir, isModule, packageName, className);
+ KrollBindingGenerator generator = new KrollBindingGenerator( outDir, packageName);
// First pass to generate the entire API tree
- for (int i = 5; i < args.length; i++) {
+ for (int i = 3; i < args.length; i++) {
generator.loadBindings(args[i]);
}
@@ -394,9 +317,6 @@ public static void main(String[] args)
generator.generateApiTree();
generator.generateBindings();
- if (RUNTIME_RHINO.equals(runtime)) {
- generator.generateRhinoBindings();
- }
}
}
View
92 ...src/java/org/appcelerator/kroll/annotations/generator/KrollGeneratedBindingsRhino.java.fm
@@ -1,92 +0,0 @@
-/**
- * Appcelerator Titanium Mobile
- * Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
- * Licensed under the terms of the Apache Public License
- * Please see the LICENSE included with this distribution for details.
- */
-
-package org.appcelerator.kroll.runtime.rhino;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Collections;
-import org.appcelerator.kroll.common.Log;
-import java.lang.reflect.Method;
-
-
-public class KrollGeneratedBindings
-{
- private static HashMap<String, GeneratedBinding> genBindings =
- new HashMap<String, GeneratedBinding>();
-
- <#-- Track the prototypes that are actually in use in the program, so
- we can dispose just those. See TIMOB-7252 for why.-->
- private static HashSet<Class<? extends Proxy>> usedPrototypeClasses =
- new HashSet<Class<? extends Proxy>>();
-
- private static final String DISPOSE = "dispose";
- private static final String TAG = "KrollGeneratedBindings";
-
- private static class GeneratedBinding
- {
- public GeneratedBinding(Class<? extends Proxy> proxyClass, String apiName)
- {
- this.proxyClass = proxyClass;
- this.apiName = apiName;
- }
-
- Class<? extends Proxy> proxyClass;
- String apiName;
- }
-
- static
- {
- <#list bindings as binding>
- genBindings.put("${binding.class}",
- new GeneratedBinding(${binding.class}Prototype.class, "${binding.apiName}"));
- </#list>
- }
-
- public static Class<? extends Proxy> getBindingClass(String name)
- {
- GeneratedBinding b = genBindings.get(name);
- if (b != null) {
- return b.proxyClass;
- }
- return null;
- }
-
- public static String getBindingName(String name)
- {
- GeneratedBinding b = genBindings.get(name);
- if (b != null) {
- return b.apiName;
- }
- return null;
- }
-
- public static void dispose()
- {
- if (usedPrototypeClasses == null) {
- return;
- }
- for (Class<? extends Proxy> cls : usedPrototypeClasses) {
- if (cls == null) {
- continue;
- }
- try {
- Method disposeMethod = cls.getMethod(DISPOSE);
- disposeMethod.invoke(null);
- } catch(Exception e) {
- Log.e(TAG, e.getClass().getSimpleName() + " disposing " + cls.getSimpleName() + ": " + e.getMessage());
- }
- }
- usedPrototypeClasses.clear();
- }
-
- public static void registerUsedPrototypeClass(Class<? extends Proxy> cls)
- {
- usedPrototypeClasses.add(cls);
- }
-}
View
2  ...d/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollJSONGenerator.java
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2010-2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
15 ...pt/src/java/org/appcelerator/kroll/annotations/generator/KrollModuleBindingsRhino.java.fm
@@ -1,15 +0,0 @@
-package ${packageName};
-
-import java.util.HashMap;
-
-import org.appcelerator.kroll.runtime.rhino.KrollBindings;
-
-public class ${className}
-{
- public static void init()
- {
- <#list bindings as binding>
- KrollBindings.addExternalBinding("${binding.class}", ${binding.class}Prototype.class);
- </#list>
- }
-}
View
2  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/KrollVisitor.java
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2010 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2010-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
181 android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBinding.fm
@@ -226,10 +226,6 @@
"javaReturnType":"jobject",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"Proxy",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaObject",
- "javaToRhinoConverter":"javaObjectToJsObject",
"typeValidation":true,
"defaultValue": "null"
},
@@ -243,10 +239,6 @@
"javaReturnType":"jobject",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"Object",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaObject",
- "javaToRhinoConverter":"javaObjectToJsObject",
"typeValidation":false,
"defaultValue": "null"
},
@@ -259,9 +251,6 @@
"javaReturnType":"jstring",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"String",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaString",
"typeValidation":false,
"defaultValue": "null"
},
@@ -275,10 +264,6 @@
"javaReturnType":"jobjectArray",
"javaValidation": true,
"javaDeleteLocalRef":true,
- "rhinoType":"Scriptable",
- "rhinoJsCast":true,
- "rhinoToJavaConverter":"jsArrayToJavaStringArray",
- "javaToRhinoConverter":"javaStringArrayToJsArray",
"defaultValue": "null"
},
"java.lang.Object":{
@@ -291,10 +276,6 @@
"javaReturnType":"jobject",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"Object",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaObject",
- "javaToRhinoConverter":"javaObjectToJsObject",
"typeValidation":false,
"defaultValue": "null"
},
@@ -308,10 +289,6 @@
"javaReturnType":"jobjectArray",
"javaValidation": true,
"javaDeleteLocalRef":true,
- "rhinoType":"Scriptable",
- "rhinoJsCast":true,
- "rhinoToJavaConverter":"jsArrayToJavaObjectArray",
- "javaToRhinoConverter":"javaObjectArrayToJsArray",
"defaultValue": "null"
},
"int[]":{
@@ -324,10 +301,6 @@
"javaReturnType":"jintArray",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"Scriptable",
- "rhinoJsCast":true,
- "rhinoToJavaConverter":"jsArrayToJavaIntArray",
- "javaToRhinoConverter":"javaIntArrayToJsArray",
"defaultValue": "null"
},
"int":{
@@ -337,9 +310,6 @@
"jvalue":"i", "signature":"I",
"javaCallMethodType":"Int",
"javaReturnType":"jint",
- "rhinoType":"Number",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaInt",
"typeValidation":false,
"defaultValue": "-1"
},
@@ -350,9 +320,6 @@
"jvalue":"s", "signature":"S",
"javaCallMethodType":"Short",
"javaReturnType":"jshort",
- "rhinoType":"Number",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaShort",
"typeValidation":false,
"defaultValue": "-1"
},
@@ -366,10 +333,6 @@
"javaReturnType":"jlongArray",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"Scriptable",
- "rhinoJsCast":true,
- "rhinoToJavaConverter":"jsArrayToJavaLongArray",
- "javaToRhinoConverter":"javaLongArrayToJsArray",
"defaultValue": "null"
},
"float[]":{
@@ -382,10 +345,6 @@
"javaReturnType":"jfloatArray",
"javaValidation":true,
"javaDeleteLocalRef":true,
- "rhinoType":"Scriptable",
- "rhinoJsCast":true,
- "rhinoToJavaConverter":"jsArrayToJavaFloatArray",
- "javaToRhinoConverter":"javaFloatArrayToJsArray",
"defaultValue": "null"
},
"long":{
@@ -395,9 +354,6 @@
"jvalue":"j", "signature":"J",
"javaCallMethodType":"Long",
"javaReturnType":"jlong",
- "rhinoType":"Number",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaLong",
"typeValidation":false,
"defaultValue": "-1"
},
@@ -408,9 +364,6 @@
"jvalue":"f", "signature":"F",
"javaCallMethodType":"Float",
"javaReturnType":"jfloat",
- "rhinoType":"Number",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaFloat",
"typeValidation":false,
"defaultValue": "-1f"
},
@@ -421,9 +374,6 @@
"jvalue":"d", "signature":"D",
"javaCallMethodType":"Double",
"javaReturnType":"jdouble",
- "rhinoType":"Number",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaDouble",
"typeValidation":false,
"defaultValue": "-1d"
},
@@ -434,16 +384,12 @@
"jvalue":"z", "signature":"Z",
"javaCallMethodType":"Boolean",
"javaReturnType":"jboolean",
- "rhinoType":"Boolean",
- "rhinoJsCast":false,
- "rhinoToJavaConverter":"jsObjectToJavaBoolean",
"defaultValue": "false"
},
"void":{
"signature":"V",
"javaCallMethodType":"Void",
- "javaReturnType":"void",
- "rhinoType":"void"
+ "javaReturnType":"void"
}
}>
@@ -635,100 +581,6 @@ fails, a JS exception is returned.
</@Proxy.listMethodArguments>
</#macro>
-<#macro verifyAndConvertJavaArgument expr index info type logOnly isOptional>
- <#if (info.typeValidation!true) && !isOptional>
- if (!(${expr} instanceof ${info.rhinoType})<#if info.javaCallMethodType == "Object"> && ${expr} != null</#if>) {
- String error = "Invalid value, expected type ${info.rhinoType}, got: " + ${expr};
- Log.e(TAG, error);
- <#if !(logOnly!false)>
- throw new IllegalArgumentException(error);
- </#if>
- }
- </#if>
-<#t>
- <#local wrapStart = "">
- <#local wrapEnd = "">
- <#if info.rhinoType != type>
- <#local wrapStart = "(" + type + ")">
- <#if type == "org.appcelerator.kroll.KrollDict">
- <#local wrapStart = "new KrollDict((HashMap) ">
- <#local wrapEnd = ")">
- </#if>
- </#if>
-<#t>
- ${type} arg${index};
- <#if isOptional>
- if (args.length <= ${index}) {
- arg${index} = ${info.defaultValue};
- } else {
- </#if>
- <#if info.rhinoJsCast>
- <#local rhinoExpr = "(" + info.rhinoType + ") " + expr>
- <#else>
- <#local rhinoExpr = expr>
- </#if>
- <#if type == "org.appcelerator.kroll.KrollDict">
- if (${expr} == null) {
- arg${index} = null;
- } else {
- </#if>
- arg${index} = ${wrapStart} TypeConverter.${info.rhinoToJavaConverter}(${rhinoExpr}, thisObj) ${wrapEnd};
- <#if type == "org.appcelerator.kroll.KrollDict">
- }
- </#if>
- <#if isOptional>
- }
- </#if>
-</#macro>
-
-<#macro convertToJavaVarArgs args start>
- int length = args.length - ${start};
- if (length < 0) {
- length = 0;
- }
-
- Object[] arg${start} = new Object[length];
- for (int i = 0; i < length; i++) {
- arg${start}[i] = TypeConverter.jsObjectToJavaObject(args[i+${start}], this);
- }
-</#macro>
-
-<#macro verifyAndConvertJavaArguments args method>
- <#-- Verify the correct argument count was provided. -->
- <@Proxy.getRequiredArgumentCount args=args ; requiredCount>
- <#if requiredCount &gt; 0>
- if (args.length < ${requiredCount}) {
- throw new IllegalArgumentException("${method.apiName}: Invalid number of arguments. Expected ${requiredCount} but got " + args.length);
- }
- </#if>
- </@Proxy.getRequiredArgumentCount>
-<#t>
- <#-- Generate argument validation and conversion code -->
- <#local varArgsIndex = -1>
- <#list args as arg>
- <#if arg.type == "java.lang.Object[]" && arg_index = args?size - 1>
- <#local varArgsIndex = arg_index>
- </#if>
- </#list>
-<#t>
- <#if method.hasInvocation>
- Scriptable scopeVars = (Scriptable) args[0];
- String sourceUrl = (String) ScriptableObject.getProperty(scopeVars, "sourceUrl");
- KrollInvocation arg0 = new KrollInvocation(sourceUrl);
- </#if>
-<#t>
- <@Proxy.listMethodArguments args=args ; index, info, type, isOptional>
- <#if type != "org.appcelerator.kroll.KrollInvocation">
- <#if index = varArgsIndex>
- <@Proxy.convertToJavaVarArgs args=args start=index/>
- <#else>
- <@Proxy.verifyAndConvertJavaArgument expr="args[" + index + "]" index=index info=info type=type logOnly=false isOptional=isOptional/>
- </#if>
- </#if>
- </@Proxy.listMethodArguments>
-<#t>
-</#macro>
-
<#macro cleanupMethodArguments args hasInvocation>
<#if hasInvocation>
env->DeleteLocalRef(jArguments[0].l);
@@ -813,37 +665,6 @@ beprovided to handle the result.
<#nested hasResult "v8Result">
</#macro>
-<#macro callJavaMethod methodArgs methodName hasInvocation returnType proxyVar>
- <#local hasResult = returnType != "void">
- <#local info = getTypeInfo(returnType)>
- <#local resultExpr = "">
-<#t>
- <#if hasResult>
- <#local resultExpr = returnType + " javaResult = ">
- </#if>
-<#t>
- <#local args>
- <#t><#list methodArgs as arg>
- <#t>arg${arg_index}
- <#t><#if arg_has_next>, </#if>
- <#t></#list>
- </#local>
- ${resultExpr}${proxyVar}.${methodName}(${args});
-<#t>
- <#if hasResult>
- <#local result>
- <#t><#if info.rhinoType == "java.lang.Object">javaResult<#t>
- <#t><#elseif !(info.javaToRhinoConverter??)>(${info.rhinoType}) javaResult<#t>
- <#t><#else>(${info.rhinoType}) TypeConverter.${info.javaToRhinoConverter}(javaResult, this)<#t>
- <#t></#if>
- </#local>
-
- ${info.rhinoType} rhinoResult = ${result};
- </#if>
-<#t>
- <#nested hasResult, "rhinoResult">
-</#macro>
-
<#macro initJNIEnv>
JNIEnv *env = titanium::JNIScope::getEnv();
if (!env) {
View
514 ...kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBindingRhino.java.fm
@@ -1,514 +0,0 @@
-/**
- * Appcelerator Titanium Mobile
- * Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
- * Licensed under the terms of the Apache Public License
- * Please see the LICENSE included with this distribution for details.
- */
-
-package ${packageName};
-
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.IdFunctionObject;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.Undefined;
-
-import org.appcelerator.kroll.KrollDict;
-import org.appcelerator.kroll.KrollInvocation;
-import org.appcelerator.kroll.KrollModule;
-import org.appcelerator.kroll.KrollProxy;
-import org.appcelerator.kroll.KrollProxySupport;
-import org.appcelerator.kroll.KrollRuntime;
-
-import org.appcelerator.kroll.runtime.rhino.KrollBindings;
-import org.appcelerator.kroll.runtime.rhino.KrollGeneratedBindings;
-import org.appcelerator.kroll.runtime.rhino.Proxy;
-import org.appcelerator.kroll.runtime.rhino.ProxyFactory;
-import org.appcelerator.kroll.runtime.rhino.RhinoRuntime;
-import org.appcelerator.kroll.runtime.rhino.TypeConverter;
-import org.appcelerator.kroll.common.Log;
-
-import java.util.HashMap;
-
-import ${packageName}.${proxyClassName};
-
-<#assign superProxy = "Proxy">
-<#if superProxyClassName??>
-import ${superPackageName}.${superProxyClassName}Prototype;
-<#assign superProxy = superProxyClassName + "Prototype">
-</#if>
-
-<#import "ProxyBinding.fm" as Proxy>
-
-<#assign className = Proxy.className(proxyClassName)>
-
-public class ${className}Prototype extends ${superProxy}
-{
- // GENERATE_SUID
-
- private static final String TAG = "${className}Prototype";
- private static final String CLASS_TAG = "${className}";
- <#assign protoVar = className?substring(0, 1)?lower_case + className?substring(1) + "Prototype">
- private static ${className}Prototype ${protoVar};
-
-<@Proxy.listApiTree ; isFirst, name, className, hasNext>
- <#if isFirst>
- // Lazy loaded child APIs
- </#if>
- private Object API_${name} = null;
-</@Proxy.listApiTree>
-
- public static ${className}Prototype getProxyPrototype()
- {
- return ${protoVar};
- }
-
- public static void dispose()
- {
- Log.d(TAG, "dispose()", Log.DEBUG_MODE);
- ${protoVar} = null;
- }
-
- public ${className}Prototype()
- {
- if (${protoVar} == null && getClass().equals(${className}Prototype.class)) {
- ${protoVar} = this;
- <#-- Enables us later to only dispose() classes that were actually used. Helps avoid VFY warnings in Android. -->
- KrollGeneratedBindings.registerUsedPrototypeClass(getClass());
- }
-
- <#if isModule>
- isModule = true;
- </#if>
- <@Proxy.listConstants ; isFirst, name, constant>
-
- <#if (constant.value)??>
- <#if constant.type = "java.lang.String">
- putConst("${name}", this, "${constant.value}");
- <#else>
- putConst("${name}", this, ${constant.value?c});
- </#if>
- <#else>
- putConst("${name}", this, ${className}.${constant.name});
- </#if>
-
- </@Proxy.listConstants>
- }
-
- public Scriptable getPrototype()
- {
- if (this == ${protoVar}) {
- return ${superProxy}.getProxyPrototype();
- }
- return ${protoVar};
- }
-
- protected Class<? extends Proxy> getParent()
- {
- return ${superProxy}.class;
- }
-
- protected KrollProxySupport createProxy(String creationUrl, Object[] args)
- {
- <#if (useTiContext!false)>
- return KrollProxy.createDeprecatedProxy(${className}.class, getRhinoObject(), args, creationUrl);
- <#else>
- return KrollProxy.createProxy(${className}.class, getRhinoObject(), args, creationUrl);
- </#if>
- }
-
- // Methods
- <@Proxy.listMethods ; isFirst, name, method>
- <#assign info = Proxy.getTypeInfo(method.returnType)>
- <#assign returnType = info.rhinoType!method.returnType>
- <#if returnType != "void">
- <#assign returnType = "Object">
- </#if>
-<#t>
- public ${returnType} ${method.apiName}(Context context, Scriptable thisObj, Object[] args)
- {
- Log.d(TAG, "${method.apiName}()", Log.DEBUG_MODE);
-
- try {
- ${className} proxy = (${className}) ((Proxy) thisObj).getProxy();
- <#if method.args?size &gt; 0>
- <@Proxy.verifyAndConvertJavaArguments method.args method/>
- </#if>
-
- <@Proxy.callJavaMethod method.args, name, method.hasInvocation, method.returnType,
- "proxy" ; hasResult, resultVar>
-
- <#if hasResult>
- return ${resultVar};
- </#if>
-
- </@Proxy.callJavaMethod>
- } catch (Throwable throwable) {
- Context.throwAsScriptRuntimeEx(throwable);
- <#if returnType != "void">return Undefined.instance;</#if>
- }
- }
-
- </@Proxy.listMethods>
-
- // Dynamic properties
- <@Proxy.listDynamicProperties ; isFirst, name, property, getSignature, setSignature>
- <#if property.get>
- <#assign info = Proxy.getTypeInfo(property.getReturnType)>
- public ${info.rhinoType} getter_${name}()
- {
- Log.d(TAG, "get ${name}", Log.DEBUG_MODE);
- ${className} proxy = (${className}) getProxy();
- Scriptable thisObj = this;
- <@Proxy.callJavaMethod property.getMethodArgs, property.getMethodName, property.getHasInvocation,
- property.getReturnType, "proxy" ; hasResult, resultVar>
- return ${resultVar};
- </@Proxy.callJavaMethod>
- }
- </#if>
-<#t>
- <#if property.set>
- public void setter_${name}(Object value)
- {
- Log.d(TAG, "set ${name}", Log.DEBUG_MODE);
- ${className} proxy = (${className}) getProxy();
- Scriptable thisObj = this;
- <#assign info = Proxy.getTypeInfo(property.setMethodArgs[0].type)>
-<#t>
- <@Proxy.verifyAndConvertJavaArgument expr="value" index=0 info=info type=property.setMethodArgs[0].type logOnly=true isOptional=false/>
-<#t>
- <@Proxy.callJavaMethod property.setMethodArgs, property.setMethodName, property.setHasInvocation,
- "void", "proxy" ; hasResult, resultVar>
- </@Proxy.callJavaMethod>
- //proxy.setProperty("${name}", value); // Commenting out for parity with V8 (don't retain from a custom setter)
- }
- </#if>
- </@Proxy.listDynamicProperties>
-
-// #string_id_map#
-
- // Prototype IDs
- private static final int
- <#assign start = 2>
- Id_constructor = 1
- <#t><#if methods?? || Proxy.hasCreateProxies() || proxyAttrs.propertyAccessors?size &gt; 0>,</#if>
- // Property IDs
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter, hasNext>
- Id_${getter} = ${start},
- Id_${setter} = ${start + 1}<#if hasNext || methods?? || Proxy.hasCreateProxies()>,</#if>
- <#assign start = start + 2>
- </@Proxy.listPropertyAccessors>
- // Method IDs
- <@Proxy.listMethods ; isFirst, name, method, signature, hasNext>
- Id_${method.apiName} = ${start}<#if hasNext || Proxy.hasCreateProxies()>,</#if>
- <#t><#assign start = start + 1>
- </@Proxy.listMethods>
-<#t>
- <@Proxy.listCreateProxies ; isFirst, createProxy, hasNext>
- Id_create${createProxy.name} = ${start}<#if hasNext>,</#if>
- <#assign start = start + 1>
- </@Proxy.listCreateProxies>;
-
-
- public static final int MAX_PROTOTYPE_ID = ${start - 1};
-
- protected int getMaxPrototypeId()
- {
- return MAX_PROTOTYPE_ID;
- }
-
- @Override
- protected int findPrototypeId(String s)
- {
- int id = 0;
-// #generated#
-// #/generated#
- return id;
- }
-
-// #/string_id_map#
-
- @Override
- protected void initPrototypeId(int id)
- {
- String name;
- int arity;
- switch (id) {
- case Id_constructor:
- arity = 0;
- name = "constructor";
- break;
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter>
- case Id_${getter}:
- arity = 0;
- name = "${getter}";
- break;
- case Id_${setter}:
- arity = 1;
- name = "${setter}";
- break;
- </@Proxy.listPropertyAccessors>
- <@Proxy.listMethods ; isFirst, name, method>
- case Id_${method.apiName}:
- <#assign arity = method.args?size>
- <#if method.hasInvocation>
- <#assign arity = arity - 1>
- </#if>
- arity = ${arity};
- name = "${method.apiName}";
- break;
- </@Proxy.listMethods>
- <@Proxy.listCreateProxies ; isFirst, createProxy, hasNext>
- case Id_create${createProxy.name}:
- arity = 1;
- name = "create${createProxy.name}";
- break;
- </@Proxy.listCreateProxies>
- default:
- super.initPrototypeId(id);
- return;
- }
- initPrototypeMethod(CLASS_TAG, id, name, arity);
- }
-
- @Override
- public Object execIdCall(IdFunctionObject f,
- Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
- {
- if (!f.hasTag(CLASS_TAG)) {
- return super.execIdCall(f, cx, scope, thisObj, args);
- }
-
- while (thisObj != null && !(thisObj instanceof ${className}Prototype)) {
- thisObj = thisObj.getPrototype();
- }
-
- ${className}Prototype proxy = (${className}Prototype) thisObj;
- int id = f.methodId();
- switch (id) {
- case Id_constructor:
- return jsConstructor(scope, args);
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter>
- case Id_${getter}:
- return proxy.getProperty("${name}");
- case Id_${setter}:
- proxy.setProperty("${name}", args[0]);
- proxy.onPropertyChanged("${name}", args[0]);
- return Undefined.instance;
- </@Proxy.listPropertyAccessors>
- <@Proxy.listMethods ; isFirst, name, method>
- case Id_${method.apiName}:
- <#assign hasReturn = (method.returnType != "void")>
- <#if hasReturn>return</#if> ${method.apiName}(cx, thisObj, args);
- <#if !hasReturn>return Undefined.instance;</#if>
- </@Proxy.listMethods>
- <@Proxy.listCreateProxies ; isFirst, createProxy, hasNext>
- case Id_create${createProxy.name}:
- return ProxyFactory.createRhinoProxy(cx, scope,
- "${createProxy.proxyClassName}", args);
- </@Proxy.listCreateProxies>
- default:
- throw new IllegalArgumentException(String.valueOf(id));
- }
- }
-
- <#if interceptor??>
- @Override
- public Object get(String name, Scriptable start)
- {
- ${className} proxy = (${className}) getProxy();
- Object result = proxy.${interceptor.name}(name);
-
- if (result != null && result instanceof Number) {
- int value = ((Number) result).intValue();
- if (value == KrollRuntime.DONT_INTERCEPT) {
- return super.get(name, start);
- }
- }
-
- return TypeConverter.javaObjectToJsObject(result, start);
- }
- </#if>
-
- <#assign start = 0>
- <#assign hasInstanceIds = dynamicProperties?? || proxyAttrs.propertyAccessors?size &gt; 0>
- <#if hasInstanceIds || Proxy.hasApiTree()>
-
-// #string_id_map#
-
- <#assign start = 1>
- // Instance IDs
- <#if superProxyClassName??>
- private static final int ISTART = 0;
- </#if>
-<#t>
- <@Proxy.listDynamicProperties ; isFirst, name, property, getSignature, setSignature>
- <#if isFirst>
- // Dynamic property IDs
- private static final int
- <#else>
- <#t>,
- </#if>
- Id_${name} = ${start}
- <#assign start = start + 1>
- </@Proxy.listDynamicProperties>;
-
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter>
- <#if isFirst>
- // Property accessor IDs
- private static final int
- <#else>
- <#t>,
- </#if>
- Id_${name} = ${start}
- <#assign start = start + 1>
- </@Proxy.listPropertyAccessors>;
-
- <@Proxy.listApiTree ; isFirst, name, className, hasNext>
- <#if isFirst>
- // Child APIs
- private static final int
- <#else>
- <#t>,
- </#if>
- Id_${name} = ${start}
- <#assign start = start + 1>
- </@Proxy.listApiTree>;
- </#if>
-
- public static final int MAX_INSTANCE_ID = ${start - 1};
-
- <#if hasInstanceIds || Proxy.hasApiTree()>
- @Override
- protected int getMaxInstanceId()
- {
- return MAX_INSTANCE_ID;
- }
-
- @Override
- protected int findInstanceIdInfo(String s)
- {
- int id = 0;
-// #generated#
-// #/generated#
- if (id == 0) {
- return id;
- }
- return instanceIdInfo(PERMANENT, id);
- }
-
-// #/string_id_map#
-
- @Override
- protected String getInstanceIdName(int id)
- {
- switch (id) {
- <@Proxy.listDynamicProperties ; isFirst, name, property, getSignature, setSignature>
- case Id_${name}:
- return "${name}";
- </@Proxy.listDynamicProperties>
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter>
- case Id_${name}:
- return "${name}";
- </@Proxy.listPropertyAccessors>
- <@Proxy.listApiTree ; isFirst, name, className, hasNext>
- case Id_${name}:
- return "${name}";
- </@Proxy.listApiTree>
- default:
- throw new IllegalArgumentException(String.valueOf(id));
- }
- }
-
- @Override
- protected Object getInstanceIdValue(int id, Scriptable start)
- {
- ${className}Prototype proxy = this;
- while (start != null && !(start instanceof ${className}Prototype)) {
- start = start.getPrototype();
- }
-
- if (start instanceof ${className}Prototype) {
- proxy = (${className}Prototype) start;
- }
-
- switch (id) {
- <@Proxy.listDynamicProperties ; isFirst, name, property, getSignature, setSignature>
- case Id_${name}:
- <#if property.get>
- return proxy.getter_${name}();
- <#else>
- return proxy.getProperty("${name}");
- </#if>
- </@Proxy.listDynamicProperties>
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter>
- case Id_${name}:
- return proxy.getProperty("${name}");
- </@Proxy.listPropertyAccessors>
- <@Proxy.listApiTree ; isFirst, name, className, hasNext>
- case Id_${name}:
- if (proxy.API_${name} == null) {
- Context context = Context.getCurrentContext();
- Scriptable scope = RhinoRuntime.getGlobalScope();
-
- proxy.API_${name} = KrollBindings.getProxyBinding(context, scope,
- "${className}", ${className}Prototype.class);
- }
- return proxy.API_${name};
- </@Proxy.listApiTree>
- default:
- throw new IllegalArgumentException(String.valueOf(id));
- }
- }
-
- @Override
- protected void setInstanceIdValue(int id, Scriptable start, Object value)
- {
- Scriptable original = start;
- ${className}Prototype proxy = this;
- while (start != null && !(start instanceof ${className}Prototype)) {
- start = start.getPrototype();
- }
-
- if (start instanceof ${className}Prototype) {
- proxy = (${className}Prototype) start;
- }
-
- switch (id) {
- <@Proxy.listDynamicProperties ; isFirst, name, property, getSignature, setSignature>
- case Id_${name}:
- <#if property.set>
- proxy.setter_${name}(value);
- <#else>
- proxy.setProperty("${name}", value);
- proxy.onPropertyChanged("${name}", value);
- </#if>
- break;
- </@Proxy.listDynamicProperties>
- <@Proxy.listPropertyAccessors ; isFirst, name, getter, setter>
- case Id_${name}:
- proxy.setProperty("${name}", value);
- proxy.onPropertyChanged("${name}", value);
- break;
- </@Proxy.listPropertyAccessors>
- <@Proxy.listApiTree ; isFirst, name, className, hasNext>
- case Id_${name}:
- if (value instanceof Proxy) {
- proxy.API_${name} = value;
- } else {
- defineProperty(original, "${name}", value, 0);
- }
- break;
- </@Proxy.listApiTree>
- default:
- throw new IllegalArgumentException(String.valueOf(id));
- }
- }
- </#if>
-
- @Override
- public String getClassName()
- {
- return CLASS_TAG;
- }
-}
View
2  ...oid/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBindingV8.cpp.fm
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
2  android/kroll-apt/src/java/org/appcelerator/kroll/annotations/generator/ProxyBindingV8.h.fm
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
4 android/runtime/common/src/java/org/appcelerator/kroll/KrollRuntime.java
@@ -171,7 +171,7 @@ public long getThreadId()
protected void doInit()
{
- // initializer for the specific runtime implementation (V8, Rhino, etc)
+ // initializer for the specific runtime implementation (V8)
initRuntime();
// Notify the main thread that the runtime has been initialized
@@ -415,7 +415,7 @@ public void setEvaluator(KrollEvaluator eval)
public void setGCFlag()
{
- // No-op in Rhino, V8 should override.
+ // No-op V8 should override.
}
public State getRuntimeState()
View
2  android/runtime/common/src/js/console.js
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2012 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2012-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
2  android/runtime/common/src/js/invoker.js
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
View
19 android/runtime/common/src/js/kroll.js
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
@@ -121,20 +121,15 @@
'\n});' ];
NativeModule.prototype.compile = function() {
- if (kroll.runtime == "rhino") {
- // We need to call back into compiled JS Scripts in Rhino
- kroll.requireNative(this.id, this.exports, NativeModule.require, this, this.filename, null, global.Ti, global.Ti, global, kroll);
- } else {
- var source = NativeModule.getSource(this.id);
- source = NativeModule.wrap(source);
+ var source = NativeModule.getSource(this.id);
+ source = NativeModule.wrap(source);
- // All native modules have their filename prefixed with ti:/
- var filename = 'ti:/' + this.filename;
+ // All native modules have their filename prefixed with ti:/
+ var filename = 'ti:/' + this.filename;
- var fn = runInThisContext(source, filename, true);
- fn(this.exports, NativeModule.require, this, this.filename, null, global.Ti, global.Ti, global, kroll);
- }
+ var fn = runInThisContext(source, filename, true);
+ fn(this.exports, NativeModule.require, this, this.filename, null, global.Ti, global.Ti, global, kroll);
this.loaded = true;
};
View
101 android/runtime/common/src/js/module.js
@@ -152,51 +152,38 @@ Module.prototype.loadExternalModule = function(id, externalBinding, context) {
var externalModule;
var returnObj;
- if (kroll.runtime === "rhino") {
- // TODO -- add support for context specific invokers in Rhino
- var bindingKey = Object.keys(externalBinding)[0];
- if (bindingKey) {
- externalModule = externalBinding[bindingKey];
- }
-
- extendModuleWithCommonJs(externalModule, id, this, context);
+ externalModule = Module.cache[id];
- return externalModule;
+ if (!externalModule) {
+ // Get the compiled bootstrap JS
+ var source = externalBinding.bootstrap;
- } else {
- externalModule = Module.cache[id];
+ // Load the native module's bootstrap JS
+ var module = new Module(id, this, context);
+ module.load(id + "/bootstrap.js", source);
- if (!externalModule) {
- // Get the compiled bootstrap JS
- var source = externalBinding.bootstrap;
+ // Bootstrap and load the module using the native bindings
+ var result = module.exports.bootstrap(externalBinding);
- // Load the native module's bootstrap JS
- var module = new Module(id, this, context);
- module.load(id + "/bootstrap.js", source);
-
- // Bootstrap and load the module using the native bindings
- var result = module.exports.bootstrap(externalBinding);
+ // Cache the external module instance
+ externalModule = Module.cache[id] = result;
+ }
- // Cache the external module instance
- externalModule = Module.cache[id] = result;
+ if (externalModule) {
+ // We cache each context-specific module wrapper
+ // on the parent module, rather than in the Module.cache
+ var wrapper = this.wrapperCache[id];
+ if (wrapper) {
+ return wrapper;
}
- if (externalModule) {
- // We cache each context-specific module wrapper
- // on the parent module, rather than in the Module.cache
- var wrapper = this.wrapperCache[id];
- if (wrapper) {
- return wrapper;
- }
-
- wrapper = this.createModuleWrapper(externalModule, sourceUrl);
+ wrapper = this.createModuleWrapper(externalModule, sourceUrl);
- extendModuleWithCommonJs(wrapper, id, this, context);
+ extendModuleWithCommonJs(wrapper, id, this, context);
- this.wrapperCache[id] = wrapper;
-
- return wrapper;
- }
+ this.wrapperCache[id] = wrapper;
+
+ return wrapper;
}
kroll.log(TAG, "Unable to load external module: " + id);
@@ -341,42 +328,14 @@ Module.prototype._runScript = function (source, filename) {
var ti = new Titanium.Wrapper(context);
- if (kroll.runtime == "rhino") {
- // Create a "context global" that's specific to each module
- var contextGlobal = context.global = {
- exports: this.exports,
- require: require,
- module: this,
- __filename: filename,
- __dirname: path.dirname(filename),
- kroll: kroll
- };
- contextGlobal.global = contextGlobal;
-
- // Add support for console logging
- contextGlobal.console = NativeModule.require('console');
-
- contextGlobal.Ti = contextGlobal.Titanium = ti;
+ // In V8, we treat external modules the same as native modules. First, we wrap the
+ // module code and then run it in the current context. This will allow external modules to
+ // access globals as mentioned in TIMOB-11752. This will also help resolve startup slowness that
+ // occurs as a result of creating a new context during startup in TIMOB-12286.
+ source = Module.wrap(source);
- // We initialize the context with the standard Javascript APIs and globals first before running the script
- var newContext = context.global = ti.global = Script.createContext(contextGlobal);
- bootstrap.bootstrapGlobals(newContext, Titanium);
-
- // The Rhino version of this API takes a custom global object but uses the same Rhino "Context".
- // It's not possible to create more than 1 Context per thread in Rhino, so contextGlobal
- // is essentially a detached global object that mimics a new context.
- return runInThisContext(source, filename, true, newContext);
-
- } else {
- // In V8, we treat external modules the same as native modules. First, we wrap the
- // module code and then run it in the current context. This will allow external modules to
- // access globals as mentioned in TIMOB-11752. This will also help resolve startup slowness that
- // occurs as a result of creating a new context during startup in TIMOB-12286.
- source = Module.wrap(source);
-
- var f = Script.runInThisContext(source, filename, true);
- return f(this.exports, require, this, filename, path.dirname(filename), ti, ti, global, kroll);
- }
+ var f = Script.runInThisContext(source, filename, true);
+ return f(this.exports, require, this, filename, path.dirname(filename), ti, ti, global, kroll);
}
// Determine the paths where the requested module could live.
View
46 android/runtime/common/src/js/titanium.js
@@ -1,7 +1,7 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
@@ -120,11 +120,6 @@ AndroidWrapper.prototype = Titanium.Android;
function createSandbox(ti, sourceUrl) {
var newSandbox = { Ti: ti, Titanium: ti };
- if (kroll.runtime == "rhino") {
- newSandbox = kroll.createSandbox(newSandbox, ti.global);
- }
-
-
// The require function we want to wrap for this context
var contextRequire = global.require;
if (ti.global) {
@@ -152,10 +147,6 @@ function createSandbox(ti, sourceUrl) {
function initScopeVars(scopeVars, sourceUrl) {
var contextUrl = sourceUrl.href;
- if (kroll.runtime == "rhino") {
- contextUrl = require("rhino").getSourceUrl(sourceUrl);
- }
-
scopeVars = scopeVars || {};
scopeVars.sourceUrl = contextUrl;
return scopeVars;
@@ -202,29 +193,22 @@ function TiInclude(filename, baseUrl, scopeVars) {
// This is called "localSandbox" so we don't overshadow the "sandbox" on global scope
var localSandbox = createSandbox(ti, scopeVars.sourceUrl);
- if (kroll.runtime == 'rhino') {
- // In Rhino we use a different code path to support pre-compiled JS
- return require("rhino").include(filename, baseUrl, localSandbox);
+ var source = getUrlSource(filename, sourceUrl),
+ wrappedSource = "with(sandbox) { " + source + "\n }",
+ filePath = sourceUrl.href.replace("app://", ""),
+ contextGlobal = ti.global;
- } else {
- var source = getUrlSource(filename, sourceUrl),
- wrappedSource = "with(sandbox) { " + source + "\n }",
- filePath = sourceUrl.href.replace("app://", ""),
- contextGlobal = ti.global;
-
- if (contextGlobal) {
- // We're running inside another window, so we run against it's context
- contextGlobal.sandbox = localSandbox;
- return Script.runInContext(wrappedSource, contextGlobal, filePath, true);
-
- } else {
- // We're running inside modules. Since we don't create a new context for modules
- // due to TIMOB-11752, we use the global V8 Context directly.
- // Put sandbox on the global scope
- sandbox = localSandbox;
- return Script.runInThisContext(wrappedSource, filePath, true);
- }
+ if (contextGlobal) {
+ // We're running inside another window, so we run against it's context
+ contextGlobal.sandbox = localSandbox;
+ return Script.runInContext(wrappedSource, contextGlobal, filePath, true);
+ } else {
+ // We're running inside modules. Since we don't create a new context for modules
+ // due to TIMOB-11752, we use the global V8 Context directly.
+ // Put sandbox on the global scope
+ sandbox = localSandbox;
+ return Script.runInThisContext(wrappedSource, filePath, true);
}
}
TiInclude.prototype = global;
View
2  android/runtime/common/src/js/url.js
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
- * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
+ * Copyright (c) 2011-2013 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
View
12 android/runtime/rhino/.classpath
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="lib" path="lib/js.jar" sourcepath="/Users/marshall/Code/rhino_titanium/src"/>
- <classpathentry kind="lib" path="/titanium-dist/lib/kroll-rhino-bindings.jar" sourcepath="generated"/>
- <classpathentry kind="lib" path="/titanium-dist/lib/kroll-rhino-js.jar"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry combineaccessrules="false" kind="src" path="/kroll-common"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
View
2  android/runtime/rhino/.gitignore
@@ -1,2 +0,0 @@
-generated
-jsbin
View
33 android/runtime/rhino/.project
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>kroll-rhino</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
View
11 android/runtime/rhino/AndroidManifest.xml
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.appcelerator.kroll.runtime.rhino"
- android:versionCode="1"
- android:versionName="1.0">
-
- <uses-sdk android:minSdkVersion="8" />
-
- <application android:label="@string/app_name">
- </application>
-</manifest>
View
209 android/runtime/rhino/build.xml
@@ -1,209 +0,0 @@
-<project>
- <property name="js.bin.dir" location="${kroll.rhino.project.dir}/jsbin"/>
- <property name="js.jar" location="${kroll.rhino.project.dir}/lib/js.jar"/>
-
- <property name="rhino.compiler" value="org.mozilla.javascript.tools.jsc.Main"/>
- <property name="rhino.idswitch" value="org.mozilla.javascript.tools.idswitch.Main"/>
-
- <property name="kroll.rhino.src.java.package.dir" location="${kroll.rhino.project.dir}/src/java/org/appcelerator/kroll/runtime/rhino"/>
-
- <property name="js.package" value="org.appcelerator.kroll.runtime.rhino.js"/>
- <property name="js.classes.dir" location="${js.bin.dir}/org/appcelerator/kroll/runtime/rhino/js"/>
- <property name="js.main.method.class" value="org.appcelerator.kroll.runtime.rhino.KrollScriptRunner"/>
-
- <path id="rhino">
- <fileset file="${js.jar}"/>
- </path>
-
- <path id="kroll.rhino.js">
- <fileset file="${dist.dir}/kroll-rhino-js.jar"/>
- </path>
-
- <target name="generate.rhino.bootstrap.js">
- <property environment="env"/>
- <condition property="python" value="${env.PYTHON}" else="python">
- <isset property="env.PYTHON"/>
- </condition>
-
- <exec executable="${python}">
- <arg file="${kroll.v8.project.dir}/tools/genBootstrap.py"/>
- <arg value="--runtime=rhino"/>
- <arg value="-o"/>
- <arg file="${kroll.rhino.project.dir}/generated"/>
- </exec>
- </target>
-
- <target name="compile.kroll.rhino.js" depends="generate.rhino.bootstrap.js">
- <mkdir dir="${js.bin.dir}"/>
-
- <path id="js.files">
- <fileset dir="${kroll.common.project.dir}/src/js" includes="*.js"/>
- <fileset dir="${kroll.rhino.project.dir}/src/js" includes="*.js"/>
- <fileset dir="${modules.dir}" includes="*/src/js/*.js"/>
- <fileset file="${kroll.rhino.project.dir}/generated/bootstrap.js"/>
- </path>
-
- <for param="js.file">
- <path refid="js.files"/>
- <sequential>
- <echo>Compiling JS: @{js.file}</echo>
-
- <var name="js.path" value="@{js.file}"/>
- <var name="js.filename" unset="true"/>
- <basename property="js.filename" file="@{js.file}"/>
-
- <if>
- <not><equals arg1="${js.filename}" arg2="kroll.js"/></not>
- <then>
- <var name="js.path" value="${java.io.tmpdir}/${js.filename}"/>
- <concat destfile="${js.path}">
- <header filtering="no">(function (exports, require, module, __filename, __dirname, Titanium, Ti, global, kroll) {
- </header>
- <path path="@{js.file}"/>
- <footer filtering="no">
- return exports;
- });</footer>
- </concat>
- </then>
- </if>
-
- <java classpathref="rhino" classname="${rhino.compiler}">
- <arg line="-opt 9 -debug"/>
- <arg line="-package ${js.package}"/>
- <arg line="-main-method-class ${js.main.method.class}"/>
- <arg value="-d"/>
- <arg file="${js.bin.dir}"/>
- <arg file="${js.path}"/>
- </java>
- </sequential>
- </for>
-
- <jar destfile="${dist.dir}/kroll-rhino-js.jar">
- <fileset dir="${js.bin.dir}" includes="**/*.class"/>
- </jar>
- </target>
-
- <macrodef name="idswitch">
- <attribute name="file"/>
- <sequential>
- <java classpathref="rhino" classname="${rhino.idswitch}" failonerror="true" logerror="true">
- <arg file="@{file}"/>
- </java>
- </sequential>
- </macrodef>
-
- <!--
- Generates an optimized id switch statement for prototype
- and instance IDs
- -->
- <target name="generate.kroll.rhino.idswitch">
- <path id="rhino.prototypes">
- <fileset dir="${kroll.rhino.src.java.package.dir}">
- <include name="modules/AssetsModule.java"/>
- <include name="EventEmitter.java"/>
- <include name="KrollGlobal.java"/>
- <include name="Proxy.java"/>
- </fileset>
- <fileset dir="${kroll.rhino.project.dir}/generated" includes="**/*.java"/>
- </path>
-
- <for param="prototype">
- <path refid="rhino.prototypes"/>
- <sequential>
- <echo>Generating IDs for @{prototype}</echo>
- <idswitch file="@{prototype}"/>
- </sequential>
- </for>
- </target>
-
- <macrodef name="path.to.classname">
- <attribute name="path"/>
- <attribute name="basedir"/>
- <attribute name="property"/>
- <sequential>
- <ti.string property="classname"
- string="@{path}"
- replace="@{basedir}${file.separator}"
- with=""/>
-
- <ti.string property="classname"
- string="${classname}"
- replace="${file.separator}"
- with="."/>
-
- <ti.string property="classname"
- string="${classname}"
- replace=".java"
- with=""/>
- <var name="@{property}" value="${classname}"/>
- </sequential>
- </macrodef>
-
- <!--
- Generates a serialVersionUID for each generated prototype,
- allowing each proxy prototype to be serialized
- -->
- <target name="generate.kroll.rhino.serials">
- <define.ti.ant.tasks/>
-
- <path id="serialver.path">
- <path refid="android"/>
- <fileset file="${js.jar}"/>
- <fileset file="${dist.dir}/kroll-common.jar"/>
- <dirset dir="${dist.classes.dir}/kroll-rhino"/>
- <dirset dir="${dist.classes.dir}/kroll-rhino-gen"/>
- </path>
-
- <path id="generated.prototypes">
- <fileset dir="${kroll.rhino.project.dir}/generated"
- includes="**/*.java"
- excludes="**/KrollGeneratedBindings.java"/>
- </path>
-
- <var name="generated.prototype.classes" value=""/>
- <for param="prototype">
- <path refid="generated.prototypes"/>
- <sequential>
- <path.to.classname path="@{prototype}"
- basedir="${kroll.rhino.project.dir}${file.separator}generated"
- property="prototype.classname"/>
- <if>
- <equals arg1="${generated.prototype.classes}" arg2=""/>
- <then>
- <var name="generated.prototype.classes" value="${prototype.classname}"/>
- </then>
- <else>
- <var name="generated.prototype.classes" value="${generated.prototype.classes},${prototype.classname}"/>
- </else>
- </if>
- </sequential>
- </for>
-
- <serialver serializableclass="${generated.prototype.classes}" property="generated.suids">
- <classpath refid="serialver.path"/>
- </serialver>
-
- <property name="kroll.rhino.tmpdir" location="${java.io.tmpdir}/kroll-rhino"/>
- <mkdir dir="${kroll.rhino.tmpdir}"/>
-
- <echo file="${kroll.rhino.tmpdir}/serials.properties" message="${generated.suids}"/>
- <property file="${kroll.rhino.tmpdir}/serials.properties" prefix="suid"/>
-
- <for param="prototype">
- <path refid="generated.prototypes"/>
- <sequential>
- <path.to.classname path="@{prototype}"
- basedir="${kroll.rhino.project.dir}${file.separator}generated"
- property="prototype.classname"/>
-
- <propertycopy property="suid" from="suid.${prototype.classname}" override="true"/>
- <echo>Generating serialVersionUID for ${prototype.classname}</echo>
- <replace file="@{prototype}" propertyfile="${kroll.rhino.tmpdir}/serials.properties">
- <replacefilter token="// GENERATE_SUID"
- value="private static final long serialVersionUID = ${suid};"/>
- </replace>
- </sequential>
- </for>
- </target>
-
-</project>
View
BIN  android/runtime/rhino/lib/js.jar
Binary file not shown
View
40 android/runtime/rhino/proguard.cfg
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native <methods>;
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
View
13 android/runtime/rhino/project.properties
@@ -1,13 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-android.library=true
-android.library.reference.1=../common
-# Project target.
-target=android-8
View
4 android/runtime/rhino/res/values/strings.xml
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">kroll-rhino</string>
-</resources>
View
19 android/runtime/rhino/src/bindings/KrollGeneratedBindings.java
@@ -1,19 +0,0 @@
-package org.appcelerator.kroll.runtime.rhino;
-
-// This class is a placeholder and doesn't actually get built, but generated
-public class KrollGeneratedBindings
-{
- public static Class<? extends Proxy> getBindingClass(String name)
- {
- return null;
- }
-
- public static String getBindingName(String name)
- {
- return null;
- }
-
- public static void dispose()
- {
- }
-}
View
146 android/runtime/rhino/src/java/org/appcelerator/kroll/runtime/rhino/EventEmitter.java
@@ -1,146 +0,0 @@
-/**
- * Appcelerator Titanium Mobile
- * Copyright (c) 2011 by Appcelerator, Inc. All Rights Reserved.
- * Licensed under the terms of the Apache Public License
- * Please see the LICENSE included with this distribution for details.
- */
-package org.appcelerator.kroll.runtime.rhino;
-
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.IdFunctionObject;
-import org.mozilla.javascript.IdScriptableObject;
-import org.mozilla.javascript.Scriptable;
-
-/**
- * A javascript object that supports listeners and event firing
- */
-public class EventEmitter extends IdScriptableObject
-{
- private static final long serialVersionUID = 4010452205917668011L;
-
- public static final String EVENT_EMITTER_TAG = "EventEmitter";
- private static EventEmitter prototype;
-
- public static void init(Scriptable scope)
- {
- EventEmitter prototype = getEventEmitterPrototype();
-
- IdFunctionObject constructor =
- prototype.exportAsJSClass(MAX_PROTOTYPE_ID, scope, false);
-
- scope.put(EVENT_EMITTER_TAG, scope, constructor);
- }
-
- public static void dispose()
- {
- prototype = null;
- }
-
- public static EventEmitter getEventEmitterPrototype()
- {
- if (prototype == null) {
- prototype = new EventEmitter();
- }
- return prototype;
- }
-
-// #string_id_map#
- private static final int
- Id_constructor = 1;
-
- protected static final int MAX_PROTOTYPE_ID = Id_constructor;
-
- @Override
- protected int findPrototypeId(String s)
- {
- int id = 0;
-// #generated# Last update: 2011-10-12 12:41:38 CDT
- L0: { id = 0; String X = null;
- if (s.length()==11) { X="constructor";id=Id_constructor; }
- if (X!=null && X!=s && !X.equals(s)) id = 0;
- break L0;
- }
-// #/generated#
- return id;
- }
-// #/string_id_map#
-
- @Override
- protected void initPrototypeId(int id)
- {
- String name;
- int arity;
- switch (id) {
- case Id_constructor:
- arity = 0;
- name = "constructor";
- break;
- default:
- super.initPrototypeId(id);
- return;
- }
- initPrototypeMethod(EVENT_EMITTER_TAG, id, name, arity);
- }
-
- @Override
- public Object execIdCall(IdFunctionObject f,
- Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
- {
- if (!f.hasTag(EVENT_EMITTER_TAG)) {
- return super.execIdCall(f, cx, scope, thisObj, args);
- }
-
- int id = f.methodId();
- switch (id) {
- case Id_constructor:
- return new EventEmitter();
- default:
- throw new IllegalArgumentException(String.valueOf(id));
- }
- }
-
- protected Object getInstanceIdValue(int id, Scriptable start)
- {
- return NOT_FOUND;
- }
-