Update documentation.

This commit is contained in:
James Roseborough
2010-05-09 05:36:03 +00:00
parent fe617fea21
commit 7c72a9feaf
2 changed files with 62 additions and 49 deletions

View File

@@ -51,7 +51,7 @@ This is an alpha release for a luaj 2.0. The most recent stable release is 1.0.
<h2>Goals of Luaj</h2> <h2>Goals of Luaj</h2>
Luaj is a lua interpreter based on the 5.1.x line of lua with the following goals in mind: Luaj is a lua interpreter based on the 5.1.x line of lua with the following goals in mind:
<ul> <ul>
<li>Java-centric implementation to take advantage of native Java features like garbage collection, and a robust class model. <li>Java-centric implementation built to use Java features like garbage collection, and class dispatch.
<li>Lightweight to allow for small, fast interpretation of lua bytecode. <li>Lightweight to allow for small, fast interpretation of lua bytecode.
<li>Complete set of libraries and tools for integration into real-world projects. <li>Complete set of libraries and tools for integration into real-world projects.
<li>Multi-platform to be able to run on JME, JSE, or JEE environments. <li>Multi-platform to be able to run on JME, JSE, or JEE environments.
@@ -63,17 +63,12 @@ In addition to the basic goals of luaj, version 2.0 is aimed
at improving on the 1.0 vm in the following aspects. at improving on the 1.0 vm in the following aspects.
<ul> <ul>
<li>Support for compiling lua into Java off-line for JME, and at runtime for JSE. <li>Support for compiling lua into Java off-line for JME, and at runtime for JSE.
<li>Faster bytecode processing for interpreted code. <li>Fastest possible bytecode processing for interpreted code.
<li>Tighter integration between lua and Java layers.
<li>Stackless implementation of interpreted code.
<li>Streamlined processing model with modular interpreter.
<li>More alignment with C API (see <a href="names.csv">names.csv</a> for details) <li>More alignment with C API (see <a href="names.csv">names.csv</a> for details)
<li>More uniform naming of classes. <li>Improved class and package naming conventions.
<li>Better package layout. <li>Improved unit tests of core classes.
<li>Better unit tests of core classes.
</ul> </ul>
<h1>2 - <a name="2">Simple Examples</a></h1> <h1>2 - <a name="2">Simple Examples</a></h1>
<h2>Run a script in Java SE</h2> <h2>Run a script in Java SE</h2>
@@ -271,43 +266,54 @@ Libraries are coded to closely match the behavior specified in
See <a href="http://www.lua.org/manual/5.1/">standard lua documentation</a> for details on the library API's See <a href="http://www.lua.org/manual/5.1/">standard lua documentation</a> for details on the library API's
<p> <p>
The following libraries are loaded by default in Java ME and Java SE platforms: The following libraries are loaded in py both <em>JsePlatform.standardGlobals()</em> and <em>JmePlatform.standardGlobals()</em>:
<pre> <pre>
base base
coroutine coroutine
io
math math
os
package package
string string
table table
</pre> </pre>
<p> <p>
The following libraries are optional, but preconfigured for some platforms and tools: The <em>JsePlatform.standardGlobals()</em> globals also include:
<pre> <pre>
io
os
debug
luajava luajava
</pre> </pre>
<h2>Optional Libraries</h2> <p>
The <em>JsePlatform.debugGlobals()</em> and <em>JsePlatform.debugGlobals()</em> functions produce globals that include:
<pre>
debug
</pre>
<h3>I/O Library</h3> <h3>I/O Library</h3>
The Java SE platform contains the <em>io</em> library by default. The implementation of the <em>io</em> library differs by platform owing to platform limitations.
<p> <p>
The Java ME platform has an optional, partial implementation of the <em>io</em> in The <em>JmePlatform.standardGlobals()</em> instantiated the io library <em>io</em> in
<pre> <pre>
src/jme/org/luaj/vm2/lib/jme/JmeIoLib.java src/jme/org/luaj/vm2/lib/jme/JmeIoLib.java
</pre> </pre>
The <em>JsePlatform.standardGlobals()</em> includes support for random access and is in
<pre>
src/jse/org/luaj/vm2/lib/jse/JseIoLib.java
</pre>
<h3>OS Library</h3> <h3>OS Library</h3>
A basic os library implementation for either Java ME or Java SE is provided ins The implementation of the <em>os</em> library also differs per platform.
<p>
The basic <em>os</em> library implementation us used by <em>JmePlatform</em> and is in:
<pre> <pre>
src/core/org/luaj/lib/OsLib.java src/core/org/luaj/lib/OsLib.java
</pre> </pre>
A slightly more complete version for Java SE is in: A richer version for use by <em>JsePlatform</em> is :
<pre> <pre>
src/jse/org/luaj/vm2/lib/jse/JseOsLib.java src/jse/org/luaj/vm2/lib/jse/JseOsLib.java
</pre> </pre>
@@ -317,31 +323,22 @@ and most time and date formatting, locales, and other features
are not implemented. are not implemented.
<h3>Debug Library</h3> <h3>Debug Library</h3>
The following library is optional: The <em>debug</em> library is not included by default by
<pre> <em>JmePlatform.standardGlobals()</em> or <em>JsePlatform.standardGlobsls()</em> .
debug
</pre>
Install from Java using: The functions <em>JmePlatform.debugGlobals()</em> and <em>JsePlatform.debugGlobsls()</em>
<pre> create globals that contain the debug library in addition to the other standard libraries.
_G.load( new DebugLib() );
</pre>
or change startup code to use: To install dynamically from lua use java-class-based require:</em>:
<pre>
LuaValue _G = JsePlatform.debugGlobals();
</pre>
To install from lua use</em>:
<pre> <pre>
require 'org.luaj.vm2.lib.DebugLib' require 'org.luaj.vm2.lib.DebugLib'
</pre> </pre>
The <em>lua</em> command line utility includes the debug library by default. The <em>lua</em> command line utility includes the <em>debug</em> library by default.
<h3>The Luajava Library</h3> <h3>The Luajava Library</h3>
The Java SE platform includes the <em>luajava</em> library, which simplifies binding to Java classes and methods. The <em>JsePlatform.standardGlobals()</em> includes the <em>luajava</em> library, which simplifies binding to Java classes and methods.
It is patterned after the original <a href="http://www.keplerproject.org/luajava/">luajava project</a>. It is patterned after the original <a href="http://www.keplerproject.org/luajava/">luajava project</a>.
<p> <p>
@@ -363,6 +360,9 @@ See a longer sample in <em>src/test/res/swingapp.lua</em> for details, or try ru
<p> <p>
The Java ME platform does not include this library, and it cannot be made to work because of the lack of a reflection API in Java SE. The Java ME platform does not include this library, and it cannot be made to work because of the lack of a reflection API in Java SE.
<p>
The <em>lua</em> connand line tool includes <em>luajava</em>.
<h1>5 - <a name="5">Building and Testing</a></h1> <h1>5 - <a name="5">Building and Testing</a></h1>
<h2>Building the jars</h2> <h2>Building the jars</h2>
@@ -374,19 +374,29 @@ Other targets exist for creating distribution file an measuring code coverage of
<h2>Unit tests</h2> <h2>Unit tests</h2>
<p> <p>
A large array of test scripts may be found in The main luaj JUnit tests are organized into a JUnit 3 suite:
<pre>
test/lua/*.lua
</pre>
<p>
A large set of JUnit tests are invoked by the JUnit 3 suite:
<pre> <pre>
test/junit/org/luaj/vm2/AllTests.lua test/junit/org/luaj/vm2/AllTests.lua
</pre> </pre>
<p> <p>
These tests are used for to produce code coverage statistics using build-coverage.xml. Unit test scripts can be found in these locations
<pre>
test/lua/*.lua
test/junit/org/luaj/vm2/compiler/lua5.1-tests.zip
test/junit/org/luaj/vm2/compiler/regressions.zip
test/junit/org/luaj/vm2/vm1/luajvm1-tests.zip
</pre>
<h2>Code coverage</h2>
<p>
A build script for running unit tests and producing code coverage statistics is in
<pre>
build-coverage.xml
</pre>
It relies on the cobertura code coverage library.
<h1>6 - <a name="6">Downloads</a></h1> <h1>6 - <a name="6">Downloads</a></h1>

View File

@@ -12,6 +12,9 @@
<artifact:dependencies filesetId="cobutura.fileset"> <artifact:dependencies filesetId="cobutura.fileset">
<dependency groupId="cobertura" artifactId="cobertura" version="1.8"/> <dependency groupId="cobertura" artifactId="cobertura" version="1.8"/>
<dependency groupId="log4j" artifactId="log4j" version="1.2.9"/>
<dependency groupId="asm" artifactId="asm" version="2.2.1"/>
<dependency groupId="oro" artifactId="oro" version="2.0.7"/>
<dependency groupId="junit" artifactId="junit" version="3.8.1"/> <dependency groupId="junit" artifactId="junit" version="3.8.1"/>
</artifact:dependencies> </artifact:dependencies>
@@ -24,10 +27,6 @@
<import file="wtk.xml"/> <import file="wtk.xml"/>
<property environment="env"/> <property environment="env"/>
<property name="antlr.version" value="3.1.3"/>
<property name="antlr.home" value="${env.ANTLR_HOME}"/>
<property name="antlr.tool.jar" value="${antlr.home}/lib/antlr-${antlr.version}.jar"/>
<property name="antlr.runtime.jar" value="${antlr.home}/lib/antlr-runtime-${antlr.version}.jar"/>
<target name="clean" description="Remove all files created by the build/test process."> <target name="clean" description="Remove all files created by the build/test process.">
<delete dir="build" failonerror="no"/> <delete dir="build" failonerror="no"/>
@@ -36,6 +35,8 @@
</target> </target>
<target name="init"> <target name="init">
<ant antfile="build.xml" target="bcel-lib"/>
<ant antfile="build.xml" target="luaj1-lib"/>
<mkdir dir="${classes.dir}" /> <mkdir dir="${classes.dir}" />
<mkdir dir="${instrumented.dir}" /> <mkdir dir="${instrumented.dir}" />
<mkdir dir="${reports.xml.dir}" /> <mkdir dir="${reports.xml.dir}" />
@@ -48,7 +49,8 @@
<javac destdir="${classes.dir}" debug="yes" target="1.5"> <javac destdir="${classes.dir}" debug="yes" target="1.5">
<classpath refid="cobertura.classpath" /> <classpath refid="cobertura.classpath" />
<classpath refid="wtk-libs" /> <classpath refid="wtk-libs" />
<classpath path="${antlr.runtime.jar}"/> <classpath path="lib/bcel-5.2.jar" />
<classpath path="lib/luaj-j2se-1.0.3.jar" />
<src path="src/core"/> <src path="src/core"/>
<src path="src/jme"/> <src path="src/jme"/>
<src path="src/jse"/> <src path="src/jse"/>
@@ -68,7 +70,6 @@
<include name="org/luaj/vm2/lib/jme/*.class" /> <include name="org/luaj/vm2/lib/jme/*.class" />
<include name="org/luaj/vm2/compiler/*.class" /> <include name="org/luaj/vm2/compiler/*.class" />
<include name="org/luaj/vm2/luajc/*.class" /> <include name="org/luaj/vm2/luajc/*.class" />
<include name="org/luaj/vm2/luajc/antlr/*.class" />
<include name="org/luaj/vm2/luajc/lst/*.class" /> <include name="org/luaj/vm2/luajc/lst/*.class" />
<include name="org/luaj/vm2/script/*.class" /> <include name="org/luaj/vm2/script/*.class" />
<exclude name="**/*Test*.class" /> <exclude name="**/*Test*.class" />
@@ -82,6 +83,8 @@
<classpath location="${classes.dir}" /> <classpath location="${classes.dir}" />
<classpath location="src/test/res" /> <classpath location="src/test/res" />
<classpath refid="cobertura.classpath" /> <classpath refid="cobertura.classpath" />
<classpath path="lib/bcel-5.2.jar" />
<classpath path="lib/luaj-j2se-1.0.3.jar" />
<formatter type="xml" /> <formatter type="xml" />
<batchtest todir="${reports.xml.dir}"> <batchtest todir="${reports.xml.dir}">
<fileset dir="test/junit"> <fileset dir="test/junit">