LScript is designed to be an extension to existing applications or APIs to allow for scripting in those projects. Currently, the project is in a state in which it would be unpractical to script in due to the verbose and nontrivial syntax. However, the project is actively being developed and new features are being added.
- Object oriented
- Garbage collected
- Several library classes included
- Runtime linking of LScript functions to native functions
Currently, LScript is only avaliable for 64-bit Windows and is built using Visual Studio 2019. It can be built inside the solution lscript.sln
.
There exist three functions relevant to starting the virtual machine, declared in lscript.h
in the lscriptlib
project. These are:
LVM ls_create_vm(int argc, const char *const argv[], void *lsAPILib)
- Creates the virtual machine with the given arguments.
argc
- The number of elements inargv
.argv
- An array of strings to be the virtual-machine arguments.lsAPILib
- A pointer to a handle in which the virtual machine is stored. For Windows, this is anHMODULE
(Generally referencinglscriptapi.dll
).
int ls_start_vm(int argc, const char *const argv[], void **threadHandle, unsigned long *threadID)
- Starts the virtual machine by running a script with the given arguments, optionally on a separate thread.
argc
- The number of elements inargv
.argv
- First element is the class name of a script on the classpath to run. The class should contain astatic
function with the namemain
taking anobjectarray
ofString
's. The rest of the elements in the array will be the arguments passed to themain
function.threadHandle
- A pointer to a pointer to a thread handle which will contain the thread created to run the virtual machine on. IfNULL
, no new thread will be created and the virtual machine will run on the thread in which this function was called.threadID
- A pointer to anunsigned long
which will contain the ID of the thread created to run the virtual machine on, if one was started. Can beNULL
.
LVM ls_create_and_start_vm(int argc, const char *const argv[], void **threadHandle, unsigned long *threadID)
- A combination of
ls_create_vm
andls_start_vm
, called in that order. argc
- The number of elements inargv
.argv
- A merged array of the arguments inls_create_vm
andls_start_vm
. All arguments should be individual elements. Arguments passed tols_create_vm
should be in the first part of the array and all arguments tols_start_vm
should be in the second part.threadHandle
- A pointer to a pointer to a thread handle which will contain the thread created to run the virtual machine on. IfNULL
, no new thread will be created and the virtual machine will run on the thread in which this function was called.lsAPILib
- A pointer to a handle in which the virtual machine is stored. For Windows, this is anHMODULE
(Generally referencinglscriptapi.dll
).
These can be used when debugging in Visual Studio by setting the Debug Command Arguments when running the lscript
project.
Below are a valid list of arguments which can be passed to ls_create_vm
. These are copied from print_help
in lscript.c
.
-version
- Displays version information and exits.-help -?
- Prints this help message.-verbose
- Enable verbose output.-nodebug
- Disables loading of debugging symbols.-verr
- Enables only verbose error output. Has no effect if-verbose
is specified.-path <path>
- Adds<path>
to the classpath.-heaps [<bytes>|K<kibibytes>|M<mebibytes>|G<gibibytes>]
- Specifies the heap size, in bytes, kibibytes, mebibytes, or gibibytes.-stacks [<bytes>|K<kibibytes>|M<mebibytes>|G<gibibytes>]
- Specifies the stack size per thread, in bytes, kibibytes, mebibytes, or gibibytes.
[classname]
- The name of a class on the classpath on which to start the virtual machine. Must contain a...
- The arguments to be passed to themain
function. Each argument is an individual element in the array. The class should contain astatic
function with the namemain
taking anobjectarray
ofString
's.
The virtual machine can be stopped with:
lvoid ls_destroy_vm(unsigned long threadWaitTime)
threadWaitTime
- The time to wait for the virtual machine thread to finish before stopping it, in milliseconds. Only affects virtual machines started on a separate thread.