Implemented Support of Java 21 VirtualThread
This commit is contained in:
19
.classpath
19
.classpath
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/core"/>
|
||||
<classpathentry excluding="org/luaj/vm2/luajc/antlr/|org/luaj/vm2/luajc/lst/|org/luaj/vm2/luajc/JavaCodeGenerator.java" kind="src" path="src/jse"/>
|
||||
<classpathentry kind="src" path="src/jme"/>
|
||||
<classpathentry kind="src" path="test/java"/>
|
||||
<classpathentry kind="src" path="test/junit"/>
|
||||
<classpathentry kind="src" path="test/lua"/>
|
||||
<classpathentry kind="src" path="examples/jse"/>
|
||||
<classpathentry kind="src" path="examples/jme"/>
|
||||
<classpathentry kind="src" path="examples/lua"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="lib/midpapi20.jar"/>
|
||||
<classpathentry kind="lib" path="lib/cldcapi11.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bcel-5.2.jar"/>
|
||||
<classpathentry kind="var" path="JRE_LIB"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
16
.idea/compiler.xml
generated
Normal file
16
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="core" />
|
||||
<module name="jme" />
|
||||
<module name="jse" />
|
||||
<module name="maven-example" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/discord.xml
generated
Normal file
7
.idea/discord.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
13
.idea/encodings.xml
generated
Normal file
13
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/core/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/core/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/jme/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/jme/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/jse/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/jse/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
25
.idea/jarRepositories.xml
generated
Normal file
25
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="oac" />
|
||||
<option name="name" value="oac" />
|
||||
<option name="url" value="https://repo.open-autonomous-connection.org/api/packages/open-autonomous-connection/maven" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/luaj.iml
generated
Normal file
9
.idea/luaj.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
18
.idea/misc.xml
generated
Normal file
18
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/examples/maven/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/core/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/jme/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/jse/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
17
.project
17
.project
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>luaj-vm</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
README.md
11
README.md
@@ -317,10 +317,6 @@ A simple example may be found in
|
||||
You must include the library <b>luaj-jme-3.0.2.jar</b> in your midlet jar.
|
||||
|
||||
<p>
|
||||
An ant script to build and run the midlet is in
|
||||
<pre>
|
||||
<a href="build-midlet.xml">build-midlet.xml</a>
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
You must install the wireless toolkit and define <em>WTK_HOME</em> for this script to work.
|
||||
@@ -428,7 +424,6 @@ Applets in browsers should use the JsePlatform. The permissions model in applet
|
||||
highly restrictive, so a specialization of the <a href="#luajava">Luajava</a> library must be used that
|
||||
uses default class loading. This is illustrated in the sample Applet
|
||||
<a href="examples/jse/SampleApplet.java">examples/jse/SampleApplet.java</a>,
|
||||
which can be built using <a href="build-applet.xml">build-applet.xml</a>.
|
||||
|
||||
|
||||
<h3>JmePlatform</h3>
|
||||
@@ -447,7 +442,6 @@ In particular Globals.finder is overridden to load as resources, so scripts shou
|
||||
colocated with class files in the MIDlet jar file. <a href="#luajava">Luajava</a> cannot be used.
|
||||
Camples code is in
|
||||
<a href="examples/jme/SampleMIDlet.java">examples/jme/SampleMIDlet.java</a>,
|
||||
which can be built using <a href="build-midlet.xml">build-midlet.xml</a>.
|
||||
|
||||
|
||||
<h2>Thread Safety</h2>
|
||||
@@ -889,10 +883,6 @@ Unit test scripts can be found in these locations
|
||||
<h2>Code coverage</h2>
|
||||
|
||||
<p>
|
||||
A build script for running unit tests and producing code coverage statistics is in
|
||||
<pre>
|
||||
<a href="build-coverage.xml">build-coverage.xml</a>
|
||||
</pre>
|
||||
|
||||
It relies on the cobertura code coverage library.
|
||||
|
||||
@@ -951,7 +941,6 @@ and at <a href="http://luaj.sourceforge.net/api/2.0/index.html">http://luaj.sour
|
||||
<li>Add explicit Globals object to manage global state, especially to imrpove thread safety </li>
|
||||
<li>Drop support for lua source to java surce (lua2java) in favor of direct java bytecode output (luajc) </li>
|
||||
<li>Remove compatibility functions like table.getn(), table.maxn(), table.foreach(), and math.log10() </li>
|
||||
<li>Add ability to create runnable jar file from lua script with sample build file build-app.xml </li>
|
||||
<li>Supply environment as second argument to LibFunction when loading via require() </li>
|
||||
<li>Fix bug 3597515 memory leak due to string caching by simplifying caching logic.</li>
|
||||
<li>Fix bug 3565008 so that short substrings are backed by short arrays.</li>
|
||||
|
||||
108
build-app.xml
108
build-app.xml
@@ -1,108 +0,0 @@
|
||||
<!-- And build script to compile lua scripts into runnable jar files using the "luajc"
|
||||
lua to java bytecode compiler.
|
||||
|
||||
Each source file is converted into a runnable jar file that takes arguments from the command line.
|
||||
For example, the program test/lua/perf/binarytrees.lua is converted to a jar that can be run with
|
||||
java -jar binarytrees.jar 15
|
||||
-->
|
||||
<project default="all">
|
||||
<import file="build.xml"/>
|
||||
|
||||
<import file="build-libs.xml"/>
|
||||
|
||||
<available file="luaj-jse-${version}.jar" property="luaj.lib.exists"/>
|
||||
|
||||
<!-- this may need to be changed when building on mac -->
|
||||
<property name="rt.jar" value="${java.home}/lib/rt.jar"/>
|
||||
|
||||
<target name="luaj-lib" unless="luaj.lib.exists">
|
||||
<antcall target="jar-jse"/>
|
||||
</target>
|
||||
|
||||
<macrodef name="perftest">
|
||||
<attribute name="cmd"/>
|
||||
<sequential>
|
||||
<echo level="info">------ @{cmd}</echo>
|
||||
<exec executable="bash">
|
||||
<arg value="-c"/>
|
||||
<arg value="time @{cmd}"/>
|
||||
</exec>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="buildappjar">
|
||||
<attribute name="luaprog"/>
|
||||
<attribute name="arg" default=""/>
|
||||
<attribute name="srcdir" default="test/lua/perf"/>
|
||||
<sequential>
|
||||
<echo level="info">=========== @{srcdir}/@{luaprog} =============</echo>
|
||||
<delete dir="build/@{luaprog}"/>
|
||||
<mkdir dir="build/@{luaprog}/class"/>
|
||||
<java classname="luajc">
|
||||
<classpath>
|
||||
<pathelement path="luaj-jse-${version}.jar"/>
|
||||
<pathelement path="lib/bcel-5.2.jar"/>
|
||||
</classpath>
|
||||
<arg value="-s"/>
|
||||
<arg path="@{srcdir}"/>
|
||||
<arg value="-d"/>
|
||||
<arg path="build/@{luaprog}/class"/>
|
||||
<arg value="-m"/>
|
||||
<arg value="-v"/>
|
||||
<arg value="@{luaprog}.lua"/>
|
||||
</java>
|
||||
<jar destfile="build/@{luaprog}.jar">
|
||||
<fileset dir="build/@{luaprog}/class"/>
|
||||
<zipfileset includes="org/luaj/vm2/*.class,org/luaj/vm2/lib/*.class,org/luaj/vm2/lib/jse/*.class,org/luaj/vm2/compiler/*.class" src="luaj-jse-${version}.jar" />
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="@{luaprog}" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<unjar src="build/@{luaprog}.jar" dest="build/@{luaprog}/unjarred"/>
|
||||
<perftest cmd="java -jar build/@{luaprog}.jar @{arg}"/>
|
||||
|
||||
<!-- The following can be adapted to produce an optimized jar.
|
||||
<taskdef resource="proguard/ant/task.properties" classpath="lib/proguard.jar" />
|
||||
<proguard>
|
||||
-injars build/@{luaprog}.jar
|
||||
-outjars build/@{luaprog}-opt.jar
|
||||
-libraryjars ${rt.jar}
|
||||
-overloadaggressively
|
||||
-repackageclasses ''
|
||||
-allowaccessmodification
|
||||
-printmapping build/@{luaprog}.map
|
||||
|
||||
-keep public class @{luaprog} {
|
||||
public static void main(java.lang.String[]);
|
||||
}
|
||||
</proguard>
|
||||
<unjar src="build/@{luaprog}-opt.jar" dest="build/@{luaprog}/unjarred-opt"/>
|
||||
<perftest cmd="java -jar build/@{luaprog}-opt.jar @{arg}"/>
|
||||
-->
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="binarytrees" depends="luaj-lib,proguard-lib">
|
||||
<buildappjar luaprog="binarytrees" arg="15"/>
|
||||
</target>
|
||||
|
||||
<target name="fannkuch" depends="luaj-lib,proguard-lib">
|
||||
<buildappjar luaprog="fannkuch" arg="10"/>
|
||||
</target>
|
||||
|
||||
<target name="nbody" depends="luaj-lib,proguard-lib">
|
||||
<buildappjar luaprog="nbody" arg="1000000"/>
|
||||
</target>
|
||||
|
||||
<target name="nsieve" depends="luaj-lib,proguard-lib">
|
||||
<buildappjar luaprog="nsieve" arg="8"/>
|
||||
</target>
|
||||
|
||||
<target name="swingapp" depends="luaj-lib,proguard-lib">
|
||||
<buildappjar luaprog="swingapp" srcdir="examples/lua"/>
|
||||
</target>
|
||||
|
||||
<target name="allappjars" depends="binarytrees,fannkuch,nbody,nsieve,swingapp"/>
|
||||
|
||||
<target name="all" depends="allappjars"/>
|
||||
</project>
|
||||
116
build-applet.xml
116
build-applet.xml
@@ -1,116 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="sample" default="main" basedir=".">
|
||||
<property file="version.properties"/>
|
||||
|
||||
<!-- find libs -->
|
||||
<import file="build-libs.xml"/>
|
||||
|
||||
<!-- main java class -->
|
||||
<property name="java.dir" value="examples/jse"/>
|
||||
<property name="java.name" value="SampleApplet"/>
|
||||
|
||||
<!-- main script -->
|
||||
<property name="script.dir" value="examples/lua"/>
|
||||
<property name="script.name" value="swingapplet"/>
|
||||
<property name="image.name" value="logo.gif"/>
|
||||
|
||||
<!-- location of luaj jar -->
|
||||
<property name="libs.dir" value="lib"/>
|
||||
<property name="luaj.jar" value="${libs.dir}/luaj-jse-${version}.jar"/>
|
||||
|
||||
<!-- location of build results -->
|
||||
<property name="build.dir" value="build/applet"/>
|
||||
|
||||
<target name="clean">
|
||||
<delete failonerror="false" dir="${build.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="dirs">
|
||||
<mkdir dir="build/applet/classes"/>
|
||||
</target>
|
||||
|
||||
<target name="classes" depends="dirs">
|
||||
<copy todir="${build.dir}">
|
||||
<fileset dir="${script.dir}" includes="${script.name}.lua,${image.name}"/>
|
||||
</copy>
|
||||
<javac destdir="${build.dir}/classes" source="1.4" target="1.4"
|
||||
classpath="${luaj.jar}" srcdir="${java.dir}" includes="${java.name}.java"/>
|
||||
</target>
|
||||
|
||||
<target name="manifest" depends="dirs">
|
||||
<manifest file="${build.dir}/MANIFEST.MF">
|
||||
<attribute name="Permissions" value="sandbox"/>
|
||||
<attribute name="Main-class" value="${java.name}"/>
|
||||
</manifest>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="classes,manifest">
|
||||
<jar destfile="${build.dir}/${script.name}.jar"
|
||||
manifest="${build.dir}/MANIFEST.MF">
|
||||
<fileset dir="${build.dir}" includes="*.lua"/>
|
||||
<fileset dir="${build.dir}/classes"/>
|
||||
<zipfileset
|
||||
src="${luaj.jar}"
|
||||
excludes="**/script/*,**/luajc/**,**/parser/**,**/ast/**,lua*"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="obf" depends="jar,proguard-lib">
|
||||
<taskdef resource="proguard/ant/task.properties" classpath="lib/proguard.jar" />
|
||||
<copy file="${build.dir}/${script.name}.jar"
|
||||
tofile="${build.dir}/${script.name}-unobfuscated.jar"/>
|
||||
<proguard>
|
||||
-injars ${build.dir}/${script.name}-unobfuscated.jar
|
||||
-outjars ${build.dir}/${script.name}.jar
|
||||
-libraryjars ${java.home}/lib/rt.jar
|
||||
-overloadaggressively
|
||||
-repackageclasses ''
|
||||
-allowaccessmodification
|
||||
-printmapping ${build.dir}/mapping.txt
|
||||
|
||||
-keep public class * extends java.applet.Applet
|
||||
|
||||
-target 1.4
|
||||
</proguard>
|
||||
</target>
|
||||
|
||||
<target name="sign" depends="obf">
|
||||
<signjar jar="${build.dir}/${script.name}.jar"
|
||||
alias="${sign.alias}"
|
||||
storepass="${sign.storepass}"
|
||||
keypass="${sign.keypass}"
|
||||
keystore="${sign.keystore}" />
|
||||
</target>
|
||||
|
||||
<target name="html" depends="dirs">
|
||||
<echoxml file="build/applet/LuajSampleApplet.html">
|
||||
<html>
|
||||
<head><title>Luaj Sample Applet</title></head>
|
||||
<body>
|
||||
<h1>Luaj Sample Applet</h1>
|
||||
Requires browser that supports applets.
|
||||
${script.name}
|
||||
<applet archive='${script.name}.jar'
|
||||
code='${java.name}.class'
|
||||
width='800'
|
||||
height='640' >
|
||||
<param name='luaj.script' value='${script.name}.lua'/>
|
||||
<param name="java_version" value="1.4+"/>
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
||||
</echoxml>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="jar,html">
|
||||
<exec executable="open" spawn="true">
|
||||
<arg value="-a Firefox"/>
|
||||
<arg path="build/applet/LuajSampleApplet.html"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="clean,sign,html,run"/>
|
||||
|
||||
<target name="main" depends="sign,html"/>
|
||||
|
||||
</project>
|
||||
@@ -1,119 +0,0 @@
|
||||
<project default="all" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
|
||||
<!--
|
||||
Run code coverage for unit tests on the luaj vm and libraries.
|
||||
-->
|
||||
|
||||
<property name="classes.dir" value="build/classes-debug" />
|
||||
<property name="instrumented.dir" value="build/instrumented" />
|
||||
<property name="reports.xml.dir" value="build/reports-junit-xml" />
|
||||
<property name="reports.html.dir" value="build/reports-junit-html" />
|
||||
<property name="coverage.xml.dir" value="build/reports-coverage-xml" />
|
||||
<property name="coverage.html.dir" value="build/reports-coverage-html" />
|
||||
<property name="cobertura.serfile" value="cobertura.ser" />
|
||||
<property name="cobertura.logfile" value="cobertura.log" />
|
||||
|
||||
<artifact:dependencies filesetId="cobutura.fileset">
|
||||
<dependency groupId="net.sourceforge.cobertura" artifactId="cobertura" version="1.9.4.1"/>
|
||||
<dependency groupId="junit" artifactId="junit" version="3.8.1"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
<path id="cobertura.classpath">
|
||||
<fileset refid="cobutura.fileset" />
|
||||
</path>
|
||||
|
||||
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
|
||||
|
||||
<import file="wtk.xml"/>
|
||||
|
||||
<property environment="env"/>
|
||||
|
||||
<target name="clean" description="Remove all files created by the build/test process.">
|
||||
<delete dir="${classes.dir}" failonerror="yes"/>
|
||||
<delete dir="${instrumented.dir}" failonerror="yes"/>
|
||||
<delete file="${cobertura.logfile}" />
|
||||
<delete file="${cobertura.serfile}" />
|
||||
</target>
|
||||
|
||||
<target name="init">
|
||||
<ant antfile="build.xml" target="bcel-lib"/>
|
||||
<ant antfile="build.xml" target="luaj1-lib"/>
|
||||
<mkdir dir="${classes.dir}" />
|
||||
<mkdir dir="${instrumented.dir}" />
|
||||
<mkdir dir="${reports.xml.dir}" />
|
||||
<mkdir dir="${reports.html.dir}" />
|
||||
<mkdir dir="${coverage.xml.dir}" />
|
||||
<mkdir dir="${coverage.html.dir}" />
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="init,wtk-or-fail">
|
||||
<javac destdir="${classes.dir}" debug="yes" target="1.5">
|
||||
<classpath refid="cobertura.classpath" />
|
||||
<classpath refid="wtk-libs" />
|
||||
<classpath path="lib/bcel-5.2.jar" />
|
||||
<src path="src/core"/>
|
||||
<src path="src/jme"/>
|
||||
<src path="src/jse"/>
|
||||
<src path="test/junit"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="instrument" depends="compile">
|
||||
<delete file="${cobertura.serfile}"/>
|
||||
<delete dir="${instrumented.dir}" failonerror="no"/>
|
||||
<cobertura-instrument datafile="${cobertura.serfile}" todir="${instrumented.dir}">
|
||||
<fileset dir="${classes.dir}">
|
||||
<include name="org/luaj/vm2/*.class" />
|
||||
<include name="org/luaj/vm2/lib/*.class" />
|
||||
<include name="org/luaj/vm2/lib/jse/*.class" />
|
||||
<include name="org/luaj/vm2/lib/jme/*.class" />
|
||||
<include name="org/luaj/vm2/compiler/*.class" />
|
||||
<include name="org/luaj/vm2/luajc/*.class" />
|
||||
<include name="org/luaj/vm2/lua2java/*.class" />
|
||||
<include name="org/luaj/vm2/parser/*.class" />
|
||||
<include name="org/luaj/vm2/ast/*.class" />
|
||||
<exclude name="**/*Test*.class" />
|
||||
</fileset>
|
||||
</cobertura-instrument>
|
||||
</target>
|
||||
|
||||
<target name="test">
|
||||
<junit fork="yes" dir="${basedir}" showoutput="yes">
|
||||
<sysproperty key="net.sourceforge.cobertura.serfile"
|
||||
file="${basedir}/${cobertura.serfile}" />
|
||||
<classpath location="${instrumented.dir}" />
|
||||
<classpath location="${classes.dir}" />
|
||||
<classpath refid="cobertura.classpath" />
|
||||
<classpath location="test/lua" />
|
||||
<classpath location="test/junit/org/luaj/vm2/compiler" />
|
||||
<classpath location="test/junit/org/luaj/vm2/vm1" />
|
||||
<classpath path="lib/bcel-5.2.jar" />
|
||||
<formatter type="xml" />
|
||||
<batchtest todir="${reports.xml.dir}">
|
||||
<fileset dir="test/junit">
|
||||
<include name="org/luaj/vm2/AllTests.java" />
|
||||
</fileset>
|
||||
</batchtest>
|
||||
</junit>
|
||||
|
||||
<junitreport todir="${reports.xml.dir}">
|
||||
<fileset dir="${reports.xml.dir}">
|
||||
<include name="TEST-*.xml" />
|
||||
</fileset>
|
||||
<report format="frames" todir="${reports.html.dir}" />
|
||||
</junitreport>
|
||||
</target>
|
||||
|
||||
<target name="report">
|
||||
<cobertura-report datafile="${cobertura.serfile}" destdir="${coverage.xml.dir}" format="xml" />
|
||||
<cobertura-report datafile="${cobertura.serfile}" destdir="${coverage.html.dir}">
|
||||
<fileset dir="src/core"/>
|
||||
<fileset dir="src/jse"/>
|
||||
<fileset dir="src/jme"/>
|
||||
</cobertura-report>
|
||||
</target>
|
||||
|
||||
<target name="coverage" depends="clean,init,compile,instrument,test,report"/>
|
||||
|
||||
<target name="all" depends="coverage" />
|
||||
|
||||
</project>
|
||||
@@ -1,56 +0,0 @@
|
||||
<project default="all-libs">
|
||||
|
||||
<available file="lib/midpapi20.jar" property="midpapi.lib.exists"/>
|
||||
<available file="lib/bcel-5.2.jar" property="bcel.lib.exists"/>
|
||||
<available file="lib/javacc.jar" property="javacc.lib.exists"/>
|
||||
<available file="lib/proguard.jar" property="proguard.lib.exists"/>
|
||||
<available file="lib/antenna-bin-1.2.0-beta.jar" property="antenna.lib.exists"/>
|
||||
<available file="lib/junit.jar" property="junit.lib.exists"/>
|
||||
<available file="lib/cobertura.jar" property="cobertura.lib.exists"/>
|
||||
<available file="lib/microemulator.jar" property="microemulator.lib.exists"/>
|
||||
|
||||
<macrodef name="download">
|
||||
<attribute name="zipname"/>
|
||||
<attribute name="jars" default="**/*.jar"/>
|
||||
<sequential>
|
||||
<mkdir dir="lib"/>
|
||||
<get src="http://luaj.sourceforge.net/lib/@{zipname}.tar.gz"
|
||||
dest="lib/@{zipname}.tar.gz"/>
|
||||
<gunzip src="lib/@{zipname}.tar.gz" dest="lib/@{zipname}.tar"/>
|
||||
<untar src="lib/@{zipname}.tar" dest="lib" overwrite="true">
|
||||
<patternset>
|
||||
<include name="@{jars}"/>
|
||||
</patternset>
|
||||
<mapper type="flatten"/>
|
||||
</untar>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="wtk-libs" unless="midpapi.lib.exists">
|
||||
<download zipname="wtk-2.5.2-api"/>
|
||||
</target>
|
||||
<target name="bcel-lib" unless="bcel.lib.exists">
|
||||
<download zipname="/bcel-5.2"/>
|
||||
</target>
|
||||
<target name="javacc-lib" unless="javacc.lib.exists">
|
||||
<download zipname="javacc-5.0"/>
|
||||
</target>
|
||||
<target name="proguard-lib" unless="proguard.lib.exists">
|
||||
<download zipname="proguard4.6"/>
|
||||
</target>
|
||||
<target name="antenna-lib" unless="antenna.lib.exists">
|
||||
<download zipname="antenna-bin-1.2.0-beta"/>
|
||||
</target>
|
||||
<target name="junit-lib" unless="junit.lib.exists">
|
||||
<download zipname="junit-3.8.2"/>
|
||||
</target>
|
||||
<target name="cobertura-lib" unless="cobertura.lib.exists">
|
||||
<download zipname="cobertura-1.9.4.1-bin"/>
|
||||
</target>
|
||||
<target name="microemulator-lib" unless="microemulator.lib.exists">
|
||||
<download zipname="microemulator-2.0.4" jars="**/microemulator.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="all-libs" depends="wtk-libs,bcel-lib,javacc-lib,proguard-lib,antenna-lib,junit-lib,cobertura-lib"/>
|
||||
|
||||
</project>
|
||||
176
build-maven.xml
176
build-maven.xml
@@ -1,176 +0,0 @@
|
||||
<project default="usage">
|
||||
<!-- Ant file to deploy to maven once the distribution is released on sourceforge.
|
||||
-->
|
||||
<property file="version.properties"/>
|
||||
|
||||
<macrodef name="write_pom">
|
||||
<attribute name="platform"/>
|
||||
<attribute name="snapshot" default=""/>
|
||||
<sequential>
|
||||
<mkdir dir="build/maven-${version}"/>
|
||||
<echo file="build/maven-${version}/luaj-@{platform}-${version}@{snapshot}.pom"><![CDATA[<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.luaj</groupId>
|
||||
<artifactId>luaj-]]>@{platform}<![CDATA[</artifactId>
|
||||
<version>]]>${version}@{snapshot}<![CDATA[</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>luaj-]]>@{platform}<![CDATA[</name>
|
||||
<description>Luaj ]]>${version}<![CDATA[ for the ]]>@{platform}<![CDATA[ platform</description>
|
||||
<url>http://sourceforge.net/projects/luaj/</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT License</name>
|
||||
<url>http://luaj.sourceforge.net/license.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>jrosebor</id>
|
||||
<name>James Roseborough</name>
|
||||
<email>jim.roseborough@luaj.org</email>
|
||||
<timezone>-8</timezone>
|
||||
<roles></roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>ifarmer</id>
|
||||
<name>Ian Farmer</name>
|
||||
<email>ian.farmer@luaj.org</email>
|
||||
<timezone>-8</timezone>
|
||||
<roles></roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<url>http://luaj.cvs.sourceforge.net/viewvc/luaj/luaj-vm/</url>
|
||||
</scm>
|
||||
</project>
|
||||
]]></echo>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="prepare_files">
|
||||
<attribute name="platform"/>
|
||||
<attribute name="snapshot" default=""/>
|
||||
<sequential>
|
||||
<mkdir dir="build/maven-${version}"/>
|
||||
<write_pom platform="@{platform}" snapshot="@{snapshot}"/>
|
||||
<copy file="luaj-${version}.zip" todir="build/maven-${version}"/>
|
||||
<unzip src="build/maven-${version}/luaj-${version}.zip" dest="build/maven-${version}"/>
|
||||
<copy file="build/maven-${version}/luaj-${version}/lib/luaj-@{platform}-${version}.jar" todir="build/maven-${version}"/>
|
||||
|
||||
<!-- make a -sources file -->
|
||||
<mkdir dir="build/maven-${version}/sources-@{platform}"/>
|
||||
<copy todir="build/maven-${version}/sources-@{platform}">
|
||||
<fileset dir="build/maven-${version}/luaj-${version}/src/core"/>
|
||||
<fileset dir="build/maven-${version}/luaj-${version}/src/@{platform}"/>
|
||||
<filterchain>
|
||||
<tokenfilter><replacestring from='"Luaj 0.0"' to='"Luaj-@{platform} ${version}"'/></tokenfilter>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<zip destfile="build/maven-${version}/luaj-@{platform}-${version}-sources.jar"
|
||||
basedir="build/maven-${version}/sources-@{platform}"/>
|
||||
|
||||
<!-- make a -javadoc file -->
|
||||
<mkdir dir="build/maven-${version}/javadoc-@{platform}"/>
|
||||
<javadoc defaultexcludes="yes"
|
||||
destdir="build/maven-${version}/javadoc-@{platform}"
|
||||
author="true"
|
||||
version="true"
|
||||
use="true"
|
||||
windowtitle="Luaj API">
|
||||
<fileset dir="build/maven-${version}/sources-@{platform}">
|
||||
<include name="org/luaj/vm/*.java"/>
|
||||
<include name="org/luaj/vm2/*.java"/>
|
||||
<include name="org/luaj/vm2/server/*.java"/>
|
||||
<include name="**/LuaC.java"/>
|
||||
<include name="**/LuaJC.java"/>
|
||||
<include name="**/lib/*/*.java"/>
|
||||
</fileset>
|
||||
<doctitle><![CDATA[<h1>Luaj API</h1>]]></doctitle>
|
||||
<bottom><![CDATA[<i>Copyright © 2007-2015 Luaj.org. All Rights Reserved.</i>]]></bottom>
|
||||
<tag name="todo" scope="all" description="To do:"/>
|
||||
<link offline="true" href="http://sourceforge.net/projects/luaj/" packagelistLoc="C:\tmp"/>
|
||||
<link href="http://sourceforge.net/projects/luaj/"/>
|
||||
</javadoc>
|
||||
<zip destfile="build/maven-${version}/luaj-@{platform}-${version}-javadoc.jar"
|
||||
basedir="build/maven-${version}/javadoc-@{platform}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="shapshot_files">
|
||||
<attribute name="platform"/>
|
||||
<sequential>
|
||||
<exec executable="mvn">
|
||||
<arg value="deploy:deploy-file"/>
|
||||
<arg value="-Durl=https://oss.sonatype.org/content/repositories/snapshots"/>
|
||||
<arg value="-DrepositoryId=nexus-releases"/>
|
||||
<arg value="-DpomFile=build/maven-${version}/luaj-@{platform}-${version}-SNAPSHOT.pom"/>
|
||||
<arg value="-Dfile=build/maven-${version}/luaj-@{platform}-${version}.jar"/>
|
||||
<arg value="-Dsources=build/maven-${version}/luaj-@{platform}-${version}-sources.jar"/>
|
||||
<arg value="-Djavadoc=build/maven-${version}/luaj-@{platform}-${version}-javadoc.jar"/>
|
||||
</exec>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="sign_and_deploy">
|
||||
<attribute name="platform"/>
|
||||
<sequential>
|
||||
<exec executable="mvn">
|
||||
<arg value="gpg:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=http://oss.sonatype.org/service/local/staging/deploy/maven2"/>
|
||||
<arg value="-DrepositoryId=nexus-releases"/>
|
||||
<arg value="-DpomFile=build/maven-${version}/luaj-@{platform}-${version}.pom"/>
|
||||
<arg value="-Dfile=build/maven-${version}/luaj-@{platform}-${version}.jar"/>
|
||||
<arg value="-Dsources=build/maven-${version}/luaj-@{platform}-${version}-sources.jar"/>
|
||||
<arg value="-Djavadoc=build/maven-${version}/luaj-@{platform}-${version}-javadoc.jar"/>
|
||||
</exec>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="prepare_and_install">
|
||||
<attribute name="platform"/>
|
||||
<sequential>
|
||||
<prepare_files platform="@{platform}"/>
|
||||
<exec executable="mvn">
|
||||
<arg value="install:install-file"/>
|
||||
<arg value="-Dfile=build/maven-${version}/luaj-@{platform}-${version}.jar"/>
|
||||
<arg value="-DpomFile=build/maven-${version}/luaj-@{platform}-${version}.pom"/>
|
||||
</exec>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="prepare_and_snapshot">
|
||||
<attribute name="platform"/>
|
||||
<sequential>
|
||||
<prepare_files platform="@{platform}" snapshot="-SNAPSHOT"/>
|
||||
<shapshot_files platform="@{platform}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="prepare_and_deploy">
|
||||
<attribute name="platform"/>
|
||||
<sequential>
|
||||
<prepare_files platform="@{platform}"/>
|
||||
<sign_and_deploy platform="@{platform}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="install">
|
||||
<prepare_and_install platform="jse"/>
|
||||
<prepare_and_install platform="jme"/>
|
||||
</target>
|
||||
|
||||
<target name="snapshot">
|
||||
<prepare_and_snapshot platform="jse"/>
|
||||
<prepare_and_snapshot platform="jme"/>
|
||||
</target>
|
||||
|
||||
<target name="deploy">
|
||||
<prepare_and_deploy platform="jse"/>
|
||||
<prepare_and_deploy platform="jme"/>
|
||||
</target>
|
||||
|
||||
<target name="usage">
|
||||
<echo level="info">Usage: ant [-Dversion=${version}] -f build-maven.xml [install | shapshot | deploy]</echo>
|
||||
</target>
|
||||
</project>
|
||||
113
build-midlet.xml
113
build-midlet.xml
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="sample" default="all" basedir=".">
|
||||
<property file="version.properties"/>
|
||||
|
||||
<!-- find libs -->
|
||||
<import file="build-libs.xml"/>
|
||||
|
||||
<!-- main script -->
|
||||
<property name="script.name" value="hello"/>
|
||||
<property name="script.dir" value="examples/lua"/>
|
||||
|
||||
<target name="clean">
|
||||
<delete failonerror="false" dir="build"/>
|
||||
</target>
|
||||
|
||||
<target name="dirs">
|
||||
<mkdir dir="build"/>
|
||||
<mkdir dir="build/tool"/>
|
||||
<mkdir dir="build/classes"/>
|
||||
</target>
|
||||
|
||||
<target name="tools" depends="dirs,bcel-lib,wtk-libs,microemulator-lib">
|
||||
<javac destdir="build/tool" classpath="lib/bcel-5.2.jar">
|
||||
<src path="src/core"/>
|
||||
<src path="src/jse"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- compile script into lua bytecode -->
|
||||
<target name="luac" depends="tools">
|
||||
<java classname="luac" classpath="build/tool">
|
||||
<arg line="-o build/classes/${script.name}.lua"/>
|
||||
<arg line="${script.dir}/${script.name}.lua"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- compile script into java bytecode -->
|
||||
<target name="luajc" depends="tools,wtk-libs">
|
||||
<java classname="luajc" classpath="build/tool:lib/bcel-5.2.jar">
|
||||
<arg line="-verbose"/>
|
||||
<arg line="-srcdir ${script.dir}"/>
|
||||
<arg line="-destdir build/classes"/>
|
||||
<arg line="${script.name}.lua"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="classes" depends="dirs,wtk-libs">
|
||||
<mkdir dir="build/midlet/src"/>
|
||||
<copy todir="build/midlet/src">
|
||||
<fileset dir="src/core"/>
|
||||
<fileset dir="src/jme"/>
|
||||
<fileset dir="examples/jme"/>
|
||||
<filterchain>
|
||||
<tokenfilter><replacestring from='"Luaj 0.0"' to='"Luaj-jme ${version}"'/></tokenfilter>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<path id="wtk-libs">
|
||||
<pathelement path="lib/cldcapi11.jar"/>
|
||||
<pathelement path="lib/midpapi20.jar"/>
|
||||
<pathelement path="lib/mmapi.jar"/>
|
||||
</path>
|
||||
<javac destdir="build/classes" encoding="utf-8" source="1.3" target="1.2" bootclasspathref="wtk-libs"
|
||||
srcdir="build/midlet/src"/>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="luajc,classes">
|
||||
<jar destfile="build/sample-plain.jar"
|
||||
basedir="build/classes"/>
|
||||
</target>
|
||||
|
||||
<target name="obf" depends="jar,proguard-lib">
|
||||
<taskdef resource="proguard/ant/task.properties" classpath="lib/proguard.jar" />
|
||||
<proguard>
|
||||
-injars build/sample-plain.jar
|
||||
-outjars build/sample.jar
|
||||
-libraryjars lib/midpapi20.jar
|
||||
-libraryjars lib/cldcapi11.jar
|
||||
-overloadaggressively
|
||||
-repackageclasses ''
|
||||
-microedition
|
||||
|
||||
-keep public class SampleMIDlet
|
||||
-keep public class * extends org.luaj.vm2.LuaValue
|
||||
</proguard>
|
||||
</target>
|
||||
|
||||
<target name="jad" depends="obf">
|
||||
<length file="build/sample.jar" property="sample.jar.length" />
|
||||
<echo level="info">Jar file length is ${sample.jar.length}</echo>
|
||||
<manifest file="build/sample.jad">
|
||||
<attribute name="Built-By" value="luaj-${version}"/>
|
||||
<attribute name="MIDlet-Name" value="Luaj ${script.name}"/>
|
||||
<attribute name="MIDlet-Version" value="${version}"/>
|
||||
<attribute name="MIDlet-Vendor" value="luaj.org"/>
|
||||
<attribute name="MIDlet-Description" value="Luaj Sample Midlet"/>
|
||||
<attribute name="MIDlet-1" value="${script.name}-${version}, , SampleMIDlet"/>
|
||||
<attribute name="MIDlet-Jar-URL" value="sample.jar"/>
|
||||
<attribute name="MIDlet-Jar-Size" value="${sample.jar.length}"/>
|
||||
<attribute name="script" value="${script.name}"/>
|
||||
</manifest>
|
||||
</target>
|
||||
|
||||
<target name="package" depends="jad,jar,obf"/>
|
||||
|
||||
<target name="run" depends="jad,jar,obf,microemulator-lib">
|
||||
<java jar="lib/microemulator.jar" fork="true">
|
||||
<arg path="build/sample.jad"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="clean,package,run"/>
|
||||
|
||||
</project>
|
||||
@@ -1,68 +0,0 @@
|
||||
<project default="all">
|
||||
<import file="build.xml"/>
|
||||
|
||||
<property name="lua.command" value="lua"/>
|
||||
<available file="luaj-jse-${version}.jar" property="luaj.lib.exists"/>
|
||||
<available file="lib/jill-1.0.1.jar" property="jill.lib.exists"/>
|
||||
<available file="lib/kahlua.jar" property="kahlua.lib.exists"/>
|
||||
<available file="lib/mochalua-1.0.jar" property="mochalua.lib.exists"/>
|
||||
|
||||
<target name="luaj-lib" unless="luaj.lib.exists">
|
||||
<antcall target="jar-jse"/>
|
||||
</target>
|
||||
|
||||
<target name="jill-lib" unless="jill.lib.exists">
|
||||
<mkdir dir="lib"/>
|
||||
<get src="http://jillcode.googlecode.com/files/jill-1.0.1.zip"
|
||||
dest="lib/jill-1.0.1.zip"/>
|
||||
<unzip src="lib/jill-1.0.1.zip" dest="lib" overwrite="true"/>
|
||||
<ant dir="lib/jill-1.0.1" target="compile"/>
|
||||
<jar destfile="lib/jill-1.0.1.jar" basedir="lib/jill-1.0.1/compiled"/>
|
||||
</target>
|
||||
|
||||
<target name="kahlua-lib" unless="kahlua.lib.exists">
|
||||
<get src="http://kahlua.googlecode.com/files/kahlua.jar"
|
||||
dest="lib/kahlua.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="mochalua-lib" unless="mochalua.lib.exists">
|
||||
<get src="http://mochalua.googlecode.com/files/Mochalua%201.0.jar"
|
||||
dest="lib/mochalua-1.0.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="perf-libs" depends="luaj-lib,bcel-lib,jill-lib,kahlua-lib,mochalua-lib"/>
|
||||
|
||||
<macrodef name="perftest">
|
||||
<attribute name="program" default="lua"/>
|
||||
<attribute name="luaprog" default="fannkuch.lua 10"/>
|
||||
<attribute name="basedir" default="test/lua/perf/"/>
|
||||
<sequential>
|
||||
<echo level="info">------ @{program} @{luaprog}</echo>
|
||||
<exec executable="bash">
|
||||
<arg value="-c"/>
|
||||
<arg value="time @{program} @{basedir}@{luaprog}"/>
|
||||
</exec>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<macrodef name="testcase">
|
||||
<attribute name="luaprog" default="fannkuch.lua 10"/>
|
||||
<sequential>
|
||||
<echo level="info">=========== @{luaprog} =============</echo>
|
||||
<perftest program="java -version" luaprog="" basedir=""/>
|
||||
<perftest program="${lua.command}" luaprog="@{luaprog}"/>
|
||||
<perftest program="java -cp luaj-jse-${version}.jar lua -n" luaprog="@{luaprog}"/>
|
||||
<perftest program="java -cp luaj-jse-${version}.jar${path.separator}lib/bcel-5.2.jar lua -b" luaprog="@{luaprog}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="alltests">
|
||||
<testcase luaprog="binarytrees.lua 15"/>
|
||||
<testcase luaprog="fannkuch.lua 10"/>
|
||||
<testcase luaprog="nbody.lua 1000000"/>
|
||||
<testcase luaprog="nsieve.lua 9"/>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="alltests"/>
|
||||
</project>
|
||||
212
build.xml
212
build.xml
@@ -1,212 +0,0 @@
|
||||
<project default="all">
|
||||
<property file="version.properties"/>
|
||||
|
||||
<property name="jar.name.jme" value="luaj-jme-${version}.jar"/>
|
||||
<property name="jar.name.jse" value="luaj-jse-${version}.jar"/>
|
||||
<property name="jar.name.sources" value="luaj-sources-${version}.jar"/>
|
||||
|
||||
<target name="clean-build">
|
||||
<delete dir="build"/>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="clean-build">
|
||||
<delete>
|
||||
<fileset dir="." includes="luaj-*.jar"/>
|
||||
</delete>
|
||||
<delete dir="examples/android/bin"/>
|
||||
<delete dir="examples/android/build"/>
|
||||
<delete dir="examples/android/gen"/>
|
||||
<delete dir="examples/android/libs"/>
|
||||
<delete dir="examples/maven/target"/>
|
||||
</target>
|
||||
|
||||
<import file="build-libs.xml"/>
|
||||
|
||||
<target name="parser" depends="javacc-lib">
|
||||
<java classname="javacc" classpath="lib/javacc.jar">
|
||||
<arg line="grammar/LuaParser.jj"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="plain-parser" depends="javacc-lib">
|
||||
<java dir="src/jse" fork="true" classname="javacc" classpath="lib/javacc.jar">
|
||||
<arg line="../../grammar/Lua52.jj"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="wtk-libs,bcel-lib">
|
||||
<delete dir="build/jme/src"/>
|
||||
<delete dir="build/jse/src"/>
|
||||
<mkdir dir="build/jme/src"/>
|
||||
<mkdir dir="build/jse/src"/>
|
||||
<mkdir dir="build/jme/classes"/>
|
||||
<mkdir dir="build/jse/classes"/>
|
||||
<copy todir="build/jme/src">
|
||||
<fileset dir="src/core"/>
|
||||
<fileset dir="src/jme"/>
|
||||
<filterchain>
|
||||
<tokenfilter><replacestring from='"Luaj 0.0"' to='"Luaj-jme ${version}"'/></tokenfilter>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<copy todir="build/jse/src">
|
||||
<fileset dir="src/core"/>
|
||||
<filterchain>
|
||||
<tokenfilter><replacestring from='"Luaj 0.0"' to='"Luaj-jse ${version}"'/></tokenfilter>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<copy todir="build/jse/src">
|
||||
<fileset dir="src/jse"/>
|
||||
<filterchain>
|
||||
<tokenfilter><replacestring from='<String>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Stat>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Exp>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Name>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Block>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<TableField>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<VarExp>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Exp.VarExp>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Object,String>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Double,String>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Integer,Integer>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Integer,LocalVariableGen>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<Exp,Integer>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<String,byte[]>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<String,Variable>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<LuaValue,String>' to=''/></tokenfilter>
|
||||
<tokenfilter><replacestring from='<LuaString,String>' to=''/></tokenfilter>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<path id="wtk-libs">
|
||||
<pathelement path="lib/cldcapi11.jar"/>
|
||||
<pathelement path="lib/midpapi20.jar"/>
|
||||
<pathelement path="lib/mmapi.jar"/>
|
||||
</path>
|
||||
<javac destdir="build/jme/classes" encoding="utf-8" source="1.3" target="1.2" bootclasspathref="wtk-libs"
|
||||
debug="on"
|
||||
srcdir="build/jme/src"/>
|
||||
<javac destdir="build/jse/classes" encoding="utf-8" source="1.3" target="1.3"
|
||||
classpath="lib/bcel-5.2.jar"
|
||||
debug="on"
|
||||
srcdir="build/jse/src"
|
||||
excludes="**/script/*,**/Lua2Java*,**/server/*,lua*"/>
|
||||
<javac destdir="build/jse/classes" encoding="utf-8" source="1.5" target="1.5"
|
||||
classpath="build/jse/classes"
|
||||
debug="on"
|
||||
srcdir="build/jse/src"
|
||||
includes="**/script/*,**/Lua2Java*,**/server/*"/>
|
||||
<javac destdir="build/jse/classes" encoding="utf-8" source="1.3" target="1.3"
|
||||
classpath="build/jse/classes"
|
||||
debug="on"
|
||||
srcdir="build/jse/src"
|
||||
includes="lua*"/>
|
||||
</target>
|
||||
|
||||
<target name="jar-jme" depends="compile">
|
||||
<jar destfile="${jar.name.jme}" basedir="build/jme/classes"/>
|
||||
</target>
|
||||
|
||||
<target name="jar-jse" depends="compile">
|
||||
<jar destfile="${jar.name.jse}">
|
||||
<fileset dir="build/jse/classes"/>
|
||||
<fileset dir="src/jse/">
|
||||
<include name="META-INF/services/**"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="jar-jse-sources" depends="compile">
|
||||
<jar destfile="${jar.name.sources}">
|
||||
<fileset dir="build/jme/src"/>
|
||||
<fileset dir="build/jse/src"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="doc">
|
||||
<delete dir="docs/api"/>
|
||||
<mkdir dir="docs/api"/>
|
||||
<javadoc defaultexcludes="yes"
|
||||
destdir="docs/api"
|
||||
author="true"
|
||||
version="true"
|
||||
use="true"
|
||||
windowtitle="Luaj API">
|
||||
<fileset dir="src/core" defaultexcludes="yes" includes="org/luaj/vm2/*.java,org/luaj/vm2/compiler/LuaC.java,org/luaj/vm2/lib/*.java"/>
|
||||
<fileset dir="src/jse" defaultexcludes="yes" includes="org/luaj/vm2/lib/jse/*.java,org/luaj/vm2/luajc/LuaJC.java,org/luaj/vm2/server/*.java"/>
|
||||
<fileset dir="src/jme" defaultexcludes="yes" includes="org/luaj/vm2/lib/jme/*.java"/>
|
||||
<doctitle><![CDATA[<h1>Luaj API</h1>]]></doctitle>
|
||||
<bottom><![CDATA[<i>Copyright © 2007-2015 Luaj.org. All Rights Reserved.</i>]]></bottom>
|
||||
<tag name="todo" scope="all" description="To do:"/>
|
||||
<group title="Core VM" packages="org.luaj.vm.*"/>
|
||||
<link offline="true" href="http://sourceforge.net/projects/luaj/" packagelistLoc="C:\tmp"/>
|
||||
<link href="http://sourceforge.net/projects/luaj/"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="all,doc">
|
||||
<delete dir="build/luaj-${version}"/>
|
||||
<mkdir dir="build/luaj-${version}/src"/>
|
||||
<mkdir dir="build/luaj-${version}/lib"/>
|
||||
<copy todir="build/luaj-${version}/src">
|
||||
<fileset dir="src">
|
||||
<exclude name="src/test/**"/>
|
||||
<exclude name="**/antlr/**"/>
|
||||
<exclude name="**/lst/**"/>
|
||||
<exclude name="**/JavaCodeGenerator.java"/>
|
||||
<exclude name="**/LuaJCompiler.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="build/luaj-${version}/test">
|
||||
<fileset dir="test"/>
|
||||
</copy>
|
||||
<copy todir="build/luaj-${version}/examples">
|
||||
<fileset dir="examples">
|
||||
<include name="android/*.*"/>
|
||||
<include name="android/assets/**"/>
|
||||
<include name="android/res/**"/>
|
||||
<include name="android/src/**"/>
|
||||
<include name="jme/*.java"/>
|
||||
<include name="jse/*.java"/>
|
||||
<include name="lua/*.*"/>
|
||||
<include name="maven/pom.xml"/>
|
||||
<include name="maven/src/**"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="build/luaj-${version}/lib">
|
||||
<fileset dir=".">
|
||||
<include name="*-${version}.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="build/luaj-${version}">
|
||||
<fileset dir=".">
|
||||
<include name="build.xml"/>
|
||||
<include name="build-libs.xml"/>
|
||||
<include name="build-coverage.xml"/>
|
||||
<include name="version.properties"/>
|
||||
<include name="wtk.xml"/>
|
||||
<include name="README.html"/>
|
||||
<include name="names.csv"/>
|
||||
<include name=".classpath"/>
|
||||
<include name=".project"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="build/luaj-${version}/docs">
|
||||
<fileset dir="docs"/>
|
||||
</copy>
|
||||
<zip destfile="luaj-${version}.zip"
|
||||
basedir="build" includes="luaj-${version}/**"/>
|
||||
</target>
|
||||
|
||||
<target name="mvn_install" depends="jar-jse">
|
||||
<exec executable="mvn">
|
||||
<arg value="install:install-file"/>
|
||||
<arg value="-Dfile=${jar.name.jse}"/>
|
||||
<arg value="-DgroupId=org.luaj"/>
|
||||
<arg value="-DartifactId=luaj-jse"/>
|
||||
<arg value="-Dversion=${version}"/>
|
||||
<arg value="-Dpackaging=jar"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="clean,jar-jme,jar-jse,jar-jse-sources"/>
|
||||
|
||||
</project>
|
||||
36
core/pom.xml
Normal file
36
core/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.openautonomousconnection.luaj</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals><goal>jar</goal></goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -502,10 +502,10 @@ public class LuaClosure extends LuaFunction {
|
||||
continue;
|
||||
|
||||
case Lua.OP_EXTRAARG:
|
||||
throw new java.lang.IllegalArgumentException("Uexecutable opcode: OP_EXTRAARG");
|
||||
throw new IllegalArgumentException("Uexecutable opcode: OP_EXTRAARG");
|
||||
|
||||
default:
|
||||
throw new java.lang.IllegalArgumentException("Illegal opcode: " + (i & 0x3f));
|
||||
throw new IllegalArgumentException("Illegal opcode: " + (i & 0x3f));
|
||||
}
|
||||
}
|
||||
} catch ( LuaError le ) {
|
||||
309
core/src/main/java/org/luaj/vm2/LuaThread.java
Normal file
309
core/src/main/java/org/luaj/vm2/LuaThread.java
Normal file
@@ -0,0 +1,309 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2007-2012 LuaJ. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2;
|
||||
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* Subclass of {@link LuaValue} that implements
|
||||
* a lua coroutine thread using Java Threads.
|
||||
* <p>
|
||||
* A LuaThread is typically created in response to a scripted call to
|
||||
* {@code coroutine.create()}
|
||||
* <p>
|
||||
* The threads must be initialized with the globals, so that
|
||||
* the global environment may be passed along according to rules of lua.
|
||||
* This is done via the constructor arguments {@link #LuaThread(Globals)} or
|
||||
* {@link #LuaThread(Globals, LuaValue)}.
|
||||
* <p>
|
||||
* The utility classes {@link org.luaj.vm2.lib.jse.JsePlatform} and
|
||||
* {@link org.luaj.vm2.lib.jme.JmePlatform}
|
||||
* see to it that this {@link Globals} are initialized properly.
|
||||
* <p>
|
||||
* The behavior of coroutine threads matches closely the behavior
|
||||
* of C coroutine library. However, because of the use of Java threads
|
||||
* to manage call state, it is possible to yield from anywhere in luaj.
|
||||
* <p>
|
||||
* Each Java thread wakes up at regular intervals and checks a weak reference
|
||||
* to determine if it can ever be resumed. If not, it throws
|
||||
* {@link OrphanedThread} which is an {@link java.lang.Error}.
|
||||
* Applications should not catch {@link OrphanedThread}, because it can break
|
||||
* the thread safety of luaj. The value controlling the polling interval
|
||||
* is {@link #thread_orphan_check_interval} and may be set by the user.
|
||||
* <p>
|
||||
* There are two main ways to abandon a coroutine. The first is to call
|
||||
* {@code yield()} from lua, or equivalently {@link Globals#yield(Varargs)},
|
||||
* and arrange to have it never resumed possibly by values passed to yield.
|
||||
* The second is to throw {@link OrphanedThread}, which should put the thread
|
||||
* in a dead state. In either case all references to the thread must be
|
||||
* dropped, and the garbage collector must run for the thread to be
|
||||
* garbage collected.
|
||||
*
|
||||
*
|
||||
* @see LuaValue
|
||||
* @see org.luaj.vm2.lib.jse.JsePlatform
|
||||
* @see org.luaj.vm2.lib.jme.JmePlatform
|
||||
* @see org.luaj.vm2.lib.CoroutineLib
|
||||
*/
|
||||
public class LuaThread extends LuaValue {
|
||||
|
||||
/** Shared metatable for lua threads. */
|
||||
public static LuaValue s_metatable;
|
||||
|
||||
/** The current number of coroutines. Should not be set. */
|
||||
public static int coroutine_count = 0;
|
||||
|
||||
/** Polling interval, in milliseconds, which each thread uses while waiting to
|
||||
* return from a yielded state to check if the lua threads is no longer
|
||||
* referenced and therefore should be garbage collected.
|
||||
* A short polling interval for many threads will consume server resources.
|
||||
* Orphaned threads cannot be detected and collected unless garbage
|
||||
* collection is run. This can be changed by Java startup code if desired.
|
||||
*/
|
||||
public static long thread_orphan_check_interval = 5000;
|
||||
|
||||
public static final String USE_PLATFORM_THREAD = "USE_PLATFORM_THREAD";
|
||||
|
||||
private static boolean SUPPORT_VIRTUAL_THREAD = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
Thread.class.getMethod("ofVirtual");
|
||||
SUPPORT_VIRTUAL_THREAD = true;
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static final int STATUS_INITIAL = 0;
|
||||
public static final int STATUS_SUSPENDED = 1;
|
||||
public static final int STATUS_RUNNING = 2;
|
||||
public static final int STATUS_NORMAL = 3;
|
||||
public static final int STATUS_DEAD = 4;
|
||||
public static final String[] STATUS_NAMES = {
|
||||
"suspended",
|
||||
"suspended",
|
||||
"running",
|
||||
"normal",
|
||||
"dead",};
|
||||
|
||||
public final State state;
|
||||
|
||||
public static final int MAX_CALLSTACK = 256;
|
||||
|
||||
/** Thread-local used by DebugLib to store debugging state.
|
||||
* This is an opaque value that should not be modified by applications. */
|
||||
public Object callstack;
|
||||
|
||||
public final Globals globals;
|
||||
|
||||
/** Error message handler for this thread, if any. */
|
||||
public LuaValue errorfunc;
|
||||
|
||||
/** Private constructor for main thread only */
|
||||
public LuaThread(Globals globals) {
|
||||
state = new State(globals, this, null);
|
||||
state.status = STATUS_RUNNING;
|
||||
this.globals = globals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a LuaThread around a function and environment
|
||||
* @param func The function to execute
|
||||
*/
|
||||
public LuaThread(Globals globals, LuaValue func) {
|
||||
LuaValue.assert_(func != null, "function cannot be null");
|
||||
state = new State(globals, this, func);
|
||||
this.globals = globals;
|
||||
}
|
||||
|
||||
public int type() {
|
||||
return LuaValue.TTHREAD;
|
||||
}
|
||||
|
||||
public String typename() {
|
||||
return "thread";
|
||||
}
|
||||
|
||||
public boolean isthread() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public LuaThread optthread(LuaThread defval) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LuaThread checkthread() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LuaValue getmetatable() {
|
||||
return s_metatable;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return STATUS_NAMES[state.status];
|
||||
}
|
||||
|
||||
public boolean isMainThread() {
|
||||
return this.state.function == null;
|
||||
}
|
||||
|
||||
public Varargs resume(Varargs args) {
|
||||
final LuaThread.State s = this.state;
|
||||
if (s.status > LuaThread.STATUS_SUSPENDED)
|
||||
return LuaValue.varargsOf(LuaValue.FALSE,
|
||||
LuaValue.valueOf("cannot resume "+(s.status==LuaThread.STATUS_DEAD? "dead": "non-suspended")+" coroutine"));
|
||||
return s.lua_resume(this, args);
|
||||
}
|
||||
|
||||
public static class State implements Runnable {
|
||||
private final Globals globals;
|
||||
final WeakReference lua_thread;
|
||||
public final LuaValue function;
|
||||
Varargs args = LuaValue.NONE;
|
||||
Varargs result = LuaValue.NONE;
|
||||
String error = null;
|
||||
|
||||
/** Hook function control state used by debug lib. */
|
||||
public LuaValue hookfunc;
|
||||
|
||||
public boolean hookline;
|
||||
public boolean hookcall;
|
||||
public boolean hookrtrn;
|
||||
public int hookcount;
|
||||
public boolean inhook;
|
||||
public int lastline;
|
||||
public int bytecodes;
|
||||
|
||||
public int status = LuaThread.STATUS_INITIAL;
|
||||
private Lock locker = new ReentrantLock();
|
||||
private Condition cond = locker.newCondition();
|
||||
|
||||
State(Globals globals, LuaThread lua_thread, LuaValue function) {
|
||||
this.globals = globals;
|
||||
this.lua_thread = new WeakReference(lua_thread);
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
locker.lock();
|
||||
try {
|
||||
try {
|
||||
Varargs a = this.args;
|
||||
this.args = LuaValue.NONE;
|
||||
this.result = function.invoke(a);
|
||||
} catch (Throwable t) {
|
||||
this.error = t.getMessage();
|
||||
} finally {
|
||||
this.status = LuaThread.STATUS_DEAD;
|
||||
cond.signal();
|
||||
}
|
||||
} finally {
|
||||
locker.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Varargs lua_resume(LuaThread new_thread, Varargs args) {
|
||||
locker.lock();
|
||||
try {
|
||||
LuaThread previous_thread = globals.running;
|
||||
try {
|
||||
globals.running = new_thread;
|
||||
this.args = args;
|
||||
if (this.status == STATUS_INITIAL) {
|
||||
this.status = STATUS_RUNNING;
|
||||
Thread t = null;
|
||||
if(SUPPORT_VIRTUAL_THREAD) {
|
||||
LuaValue setting = globals.get(USE_PLATFORM_THREAD);
|
||||
if(setting.isnil()) {//default
|
||||
if(Thread.currentThread().isVirtual()) {
|
||||
t = Thread.ofVirtual().name("Coroutine-"+(++coroutine_count)).start(this);
|
||||
}
|
||||
} else {
|
||||
if(!setting.toboolean()) {
|
||||
t = Thread.ofVirtual().name("Coroutine-"+(++coroutine_count)).start(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t == null){
|
||||
new Thread(this, "Coroutine-"+(++coroutine_count)).start();
|
||||
}
|
||||
} else {
|
||||
cond.signal();
|
||||
}
|
||||
if (previous_thread != null)
|
||||
previous_thread.state.status = STATUS_NORMAL;
|
||||
this.status = STATUS_RUNNING;
|
||||
cond.await();
|
||||
return (this.error != null?
|
||||
LuaValue.varargsOf(LuaValue.FALSE, LuaValue.valueOf(this.error)):
|
||||
LuaValue.varargsOf(LuaValue.TRUE, this.result));
|
||||
} catch (InterruptedException ie) {
|
||||
throw new OrphanedThread();
|
||||
} finally {
|
||||
this.args = LuaValue.NONE;
|
||||
this.result = LuaValue.NONE;
|
||||
this.error = null;
|
||||
globals.running = previous_thread;
|
||||
if (previous_thread != null)
|
||||
globals.running.state.status =STATUS_RUNNING;
|
||||
}
|
||||
} finally {
|
||||
locker.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Varargs lua_yield(Varargs args) {
|
||||
locker.lock();
|
||||
try {
|
||||
try {
|
||||
this.result = args;
|
||||
this.status = STATUS_SUSPENDED;
|
||||
cond.signal();
|
||||
do {
|
||||
cond.await(thread_orphan_check_interval,TimeUnit.MILLISECONDS);
|
||||
if (this.lua_thread.get() == null) {
|
||||
this.status = STATUS_DEAD;
|
||||
throw new OrphanedThread();
|
||||
}
|
||||
} while (this.status == STATUS_SUSPENDED);
|
||||
return this.args;
|
||||
} catch (InterruptedException ie) {
|
||||
this.status = STATUS_DEAD;
|
||||
throw new OrphanedThread();
|
||||
} finally {
|
||||
this.args = LuaValue.NONE;
|
||||
this.result = LuaValue.NONE;
|
||||
}
|
||||
} finally {
|
||||
locker.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3402,8 +3402,8 @@ public class LuaValue extends Varargs {
|
||||
switch ( v.length ) {
|
||||
case 0: return NONE;
|
||||
case 1: return v[0];
|
||||
case 2: return new Varargs.PairVarargs(v[0],v[1]);
|
||||
default: return new Varargs.ArrayVarargs(v,NONE);
|
||||
case 2: return new PairVarargs(v[0],v[1]);
|
||||
default: return new ArrayVarargs(v,NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3419,12 +3419,12 @@ public class LuaValue extends Varargs {
|
||||
switch ( v.length ) {
|
||||
case 0: return r;
|
||||
case 1: return r.narg()>0?
|
||||
(Varargs) new Varargs.PairVarargs(v[0],r):
|
||||
(Varargs) new PairVarargs(v[0],r):
|
||||
(Varargs) v[0];
|
||||
case 2: return r.narg()>0?
|
||||
(Varargs) new Varargs.ArrayVarargs(v,r):
|
||||
(Varargs) new Varargs.PairVarargs(v[0],v[1]);
|
||||
default: return new Varargs.ArrayVarargs(v,r);
|
||||
(Varargs) new ArrayVarargs(v,r):
|
||||
(Varargs) new PairVarargs(v[0],v[1]);
|
||||
default: return new ArrayVarargs(v,r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3441,8 +3441,8 @@ public class LuaValue extends Varargs {
|
||||
switch ( length ) {
|
||||
case 0: return NONE;
|
||||
case 1: return v[offset];
|
||||
case 2: return new Varargs.PairVarargs(v[offset+0],v[offset+1]);
|
||||
default: return new Varargs.ArrayPartVarargs(v, offset, length, NONE);
|
||||
case 2: return new PairVarargs(v[offset+0],v[offset+1]);
|
||||
default: return new ArrayPartVarargs(v, offset, length, NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3463,12 +3463,12 @@ public class LuaValue extends Varargs {
|
||||
switch ( length ) {
|
||||
case 0: return more;
|
||||
case 1: return more.narg()>0?
|
||||
(Varargs) new Varargs.PairVarargs(v[offset],more):
|
||||
(Varargs) new PairVarargs(v[offset],more):
|
||||
(Varargs) v[offset];
|
||||
case 2: return more.narg()>0?
|
||||
(Varargs) new Varargs.ArrayPartVarargs(v,offset,length,more):
|
||||
(Varargs) new Varargs.PairVarargs(v[offset],v[offset+1]);
|
||||
default: return new Varargs.ArrayPartVarargs(v,offset,length,more);
|
||||
(Varargs) new ArrayPartVarargs(v,offset,length,more):
|
||||
(Varargs) new PairVarargs(v[offset],v[offset+1]);
|
||||
default: return new ArrayPartVarargs(v,offset,length,more);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3485,7 +3485,7 @@ public class LuaValue extends Varargs {
|
||||
public static Varargs varargsOf(LuaValue v, Varargs r) {
|
||||
switch ( r.narg() ) {
|
||||
case 0: return v;
|
||||
default: return new Varargs.PairVarargs(v,r);
|
||||
default: return new PairVarargs(v,r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3502,8 +3502,8 @@ public class LuaValue extends Varargs {
|
||||
*/
|
||||
public static Varargs varargsOf(LuaValue v1,LuaValue v2,Varargs v3) {
|
||||
switch ( v3.narg() ) {
|
||||
case 0: return new Varargs.PairVarargs(v1,v2);
|
||||
default: return new Varargs.ArrayPartVarargs(new LuaValue[]{v1,v2}, 0, 2, v3);
|
||||
case 0: return new PairVarargs(v1,v2);
|
||||
default: return new ArrayPartVarargs(new LuaValue[]{v1,v2}, 0, 2, v3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
package org.luaj.vm2;
|
||||
|
||||
/**
|
||||
* {@link java.lang.Error} sublcass that indicates a lua thread that is no
|
||||
* {@link Error} sublcass that indicates a lua thread that is no
|
||||
* longer referenced has been detected.
|
||||
* <p>
|
||||
* The java thread in which this is thrown should correspond to a
|
||||
@@ -537,7 +537,7 @@ public abstract class Varargs {
|
||||
if (newstart == this.end)
|
||||
return v.arg(this.end);
|
||||
if (newstart == this.end-1)
|
||||
return new Varargs.PairVarargs(v.arg(this.end-1), v.arg(this.end));
|
||||
return new PairVarargs(v.arg(this.end-1), v.arg(this.end));
|
||||
return new SubVarargs(v, newstart, this.end);
|
||||
}
|
||||
return new SubVarargs(v, newstart, this.end);
|
||||
@@ -168,7 +168,7 @@ public class DumpState {
|
||||
break;
|
||||
case NUMBER_FORMAT_INTS_ONLY:
|
||||
if ( ! ALLOW_INTEGER_CASTING && ! o.isint() )
|
||||
throw new java.lang.IllegalArgumentException("not an integer: "+o);
|
||||
throw new IllegalArgumentException("not an integer: "+o);
|
||||
writer.write(LuaValue.TNUMBER);
|
||||
dumpInt(o.toint());
|
||||
break;
|
||||
@@ -1,24 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Luaj.org. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
* Copyright (c) 2009 Luaj.org. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2.compiler;
|
||||
|
||||
import java.util.Hashtable;
|
||||
@@ -479,7 +479,7 @@ public class FuncState extends Constants {
|
||||
return ((Integer) h.get(v)).intValue();
|
||||
}
|
||||
final int idx = this.nk;
|
||||
this.h.put(v, new Integer(idx));
|
||||
this.h.put(v, idx);
|
||||
final Prototype f = this.f;
|
||||
if (f.k == null || nk + 1 >= f.k.length)
|
||||
f.k = realloc( f.k, nk*2 + 1 );
|
||||
@@ -1,24 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Luaj.org. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
* Copyright (c) 2009 Luaj.org. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2.compiler;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -170,7 +170,7 @@ public class LexState extends Constants {
|
||||
static {
|
||||
for ( int i=0; i<NUM_RESERVED; i++ ) {
|
||||
LuaString ts = (LuaString) LuaValue.valueOf( luaX_tokens[i] );
|
||||
RESERVED.put(ts, new Integer(FIRST_RESERVED+i));
|
||||
RESERVED.put(ts, FIRST_RESERVED+i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1755,7 +1755,7 @@ public class LexState extends Constants {
|
||||
dyd.label[l].nactvar = fs.bl.nactvar;
|
||||
}
|
||||
findgotos(dyd.label[l]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void whilestat (int line) {
|
||||
@@ -43,7 +43,7 @@ import org.luaj.vm2.lib.BaseLib;
|
||||
* using a user-supplied environment.
|
||||
*
|
||||
* <p>
|
||||
* Implements the {@link org.luaj.vm2.Globals.Compiler} interface for loading
|
||||
* Implements the {@link Globals.Compiler} interface for loading
|
||||
* initialized chunks, which is an interface common to
|
||||
* lua bytecode compiling and java bytecode compiling.
|
||||
*
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#Sun Mar 01 11:42:21 CET 2026
|
||||
gradle.version=9.0.0
|
||||
@@ -7,16 +7,25 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>maven-example</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>oac</id>
|
||||
<url>https://repo.open-autonomous-connection.org/api/packages/open-autonomous-connection/maven</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.luaj</groupId>
|
||||
<artifactId>luaj-jse</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.openautonomousconnection.luaj</groupId>
|
||||
<artifactId>jse</artifactId>
|
||||
<version>VERSION</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
122
jme/pom.xml
Normal file
122
jme/pom.xml
Normal file
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.openautonomousconnection.luaj</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jme</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openautonomousconnection.luaj</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jme</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.WTK_HOME</name>
|
||||
</property>
|
||||
</activation>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals><goal>copy-resources</goal></goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/generated-sources/luaj-jme</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/../luaj-core/src/main/java</directory>
|
||||
<includes><include>**/*.java</include></includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/java</directory>
|
||||
<includes><include>**/*.java</include></includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>rewrite-branding</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals><goal>replace</goal></goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.directory}/generated-sources/luaj-jme</basedir>
|
||||
<includes><include>**/*.java</include></includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>"Luaj 0.0"</token>
|
||||
<value>"${luaj.brand.jme}"</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-generated-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals><goal>add-source</goal></goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${project.build.directory}/generated-sources/luaj-jme</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<release>8</release>
|
||||
<compilerArgs>
|
||||
<arg>-bootclasspath</arg>
|
||||
<arg>${env.WTK_HOME}/lib/cldcapi11.jar${path.separator}${env.WTK_HOME}/lib/midpapi20.jar${path.separator}${env.WTK_HOME}/lib/mmapi.jar</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals><goal>jar</goal></goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.openautonomousconnection.luaj;
|
||||
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
public class Main {
|
||||
static void main() {
|
||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
IO.println(String.format("Hello and welcome!"));
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
IO.println("i = " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
134
jse/pom.xml
Normal file
134
jse/pom.xml
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.openautonomousconnection.luaj</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jse</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openautonomousconnection.luaj</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals><goal>copy-resources</goal></goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/generated-sources/luaj-jse</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/../luaj-core/src/main/java</directory>
|
||||
<includes><include>**/*.java</include></includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/java</directory>
|
||||
<includes><include>**/*.java</include></includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>rewrite-branding-and-cleanup</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals><goal>replace</goal></goals>
|
||||
<configuration>
|
||||
<basedir>${project.build.directory}/generated-sources/luaj-jse</basedir>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>"Luaj 0.0"</token>
|
||||
<value>"${luaj.brand.jse}"</value>
|
||||
</replacement>
|
||||
<replacement><token><String></token><value></value></replacement>
|
||||
<replacement><token><Stat></token><value></value></replacement>
|
||||
<replacement><token><Exp></token><value></value></replacement>
|
||||
<replacement><token><Name></token><value></value></replacement>
|
||||
<replacement><token><Block></token><value></value></replacement>
|
||||
<replacement><token><TableField></token><value></value></replacement>
|
||||
<replacement><token><VarExp></token><value></value></replacement>
|
||||
<replacement><token><Exp.VarExp></token><value></value></replacement>
|
||||
<replacement><token><Object,String></token><value></value></replacement>
|
||||
<replacement><token><Double,String></token><value></value></replacement>
|
||||
<replacement><token><Integer,Integer></token><value></value></replacement>
|
||||
<replacement><token><Integer,LocalVariableGen></token><value></value></replacement>
|
||||
<replacement><token><Exp,Integer></token><value></value></replacement>
|
||||
<replacement><token><String,byte[]></token><value></value></replacement>
|
||||
<replacement><token><String,Variable></token><value></value></replacement>
|
||||
<replacement><token><LuaValue,String></token><value></value></replacement>
|
||||
<replacement><token><LuaString,String></token><value></value></replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-generated-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals><goal>add-source</goal></goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${project.build.directory}/generated-sources/luaj-jse</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals><goal>jar</goal></goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -155,7 +155,7 @@ abstract public class Visitor {
|
||||
public void visitVars(List<VarExp> vars) {
|
||||
if ( vars != null )
|
||||
for ( int i=0, n=vars.size(); i<n; i++ )
|
||||
((Exp.VarExp)vars.get(i)).accept(this);
|
||||
((VarExp)vars.get(i)).accept(this);
|
||||
}
|
||||
public void visitExps(List<Exp> exps) {
|
||||
if ( exps != null )
|
||||
@@ -34,7 +34,7 @@ import org.luaj.vm2.Prototype;
|
||||
import org.luaj.vm2.compiler.LuaC;
|
||||
|
||||
/**
|
||||
* Implementation of {@link org.luaj.vm2.Globals.Compiler} which does direct
|
||||
* Implementation of {@link Globals.Compiler} which does direct
|
||||
* lua-to-java-bytecode compiling.
|
||||
* <p>
|
||||
* By default, when using {@link org.luaj.vm2.lib.jse.JsePlatform} or
|
||||
@@ -59,7 +59,7 @@ import org.luaj.vm2.compiler.LuaC;
|
||||
*
|
||||
* @see Globals#compiler
|
||||
* @see #install(Globals)
|
||||
* @see org.luaj.vm2.compiler.LuaC
|
||||
* @see LuaC
|
||||
* @see LuaValue
|
||||
*/
|
||||
public class LuaJC implements Globals.Loader {
|
||||
@@ -1741,7 +1741,7 @@ public class LuaParser implements LuaParserConstants {
|
||||
throw generateParseException();
|
||||
}
|
||||
|
||||
static private final class LookaheadSuccess extends java.lang.Error { }
|
||||
static private final class LookaheadSuccess extends Error { }
|
||||
final private LookaheadSuccess jj_ls = new LookaheadSuccess();
|
||||
private boolean jj_scan_token(int kind) {
|
||||
if (jj_scanpos == jj_lastpos) {
|
||||
@@ -1791,7 +1791,7 @@ public class LuaParser implements LuaParserConstants {
|
||||
return (jj_ntk = jj_nt.kind);
|
||||
}
|
||||
|
||||
private java.util.List jj_expentries = new java.util.ArrayList();
|
||||
private List jj_expentries = new ArrayList();
|
||||
private int[] jj_expentry;
|
||||
private int jj_kind = -1;
|
||||
private int[] jj_lasttokens = new int[100];
|
||||
@@ -1806,7 +1806,7 @@ public class LuaParser implements LuaParserConstants {
|
||||
for (int i = 0; i < jj_endpos; i++) {
|
||||
jj_expentry[i] = jj_lasttokens[i];
|
||||
}
|
||||
jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) {
|
||||
jj_entries_loop: for (Iterator it = jj_expentries.iterator(); it.hasNext();) {
|
||||
int[] oldentry = (int[])(it.next());
|
||||
if (oldentry.length == jj_expentry.length) {
|
||||
for (int i = 0; i < jj_expentry.length; i++) {
|
||||
@@ -1,24 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008-2013 LuaJ. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
* Copyright (c) 2008-2013 LuaJ. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2.script;
|
||||
|
||||
import java.io.*;
|
||||
@@ -244,8 +244,8 @@ public class LuaScriptEngine extends AbstractScriptEngine implements ScriptEngin
|
||||
case LuaValue.TSTRING: return luajValue.tojstring();
|
||||
case LuaValue.TUSERDATA: return luajValue.checkuserdata(Object.class);
|
||||
case LuaValue.TNUMBER: return luajValue.isinttype()?
|
||||
(Object) new Integer(luajValue.toint()):
|
||||
(Object) new Double(luajValue.todouble());
|
||||
luajValue.toint():
|
||||
luajValue.todouble();
|
||||
default: return luajValue;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user