Просмотр исходного кода

Lua api documentation (#5164)

* add/update copyright notice

* Lua api documentation

* Mostly copy/pasted from https://www.lua.org/manual/,
* I added ThreadState.Normal in Coroutine, I read from the docs that seems also a state
Mark Knol 9 лет назад
Родитель
Сommit
713618d549
10 измененных файлов с 560 добавлено и 18 удалено
  1. 60 4
      std/lua/Coroutine.hx
  2. 90 0
      std/lua/Debug.hx
  3. 66 0
      std/lua/Io.hx
  4. 4 2
      std/lua/Lib.hx
  5. 140 3
      std/lua/Lua.hx
  6. 102 4
      std/lua/NativeStringTools.hx
  7. 63 4
      std/lua/Os.hx
  8. 32 0
      std/lua/Package.hx
  9. 3 0
      std/lua/Table.hx
  10. 0 1
      std/lua/Thread.hx

+ 60 - 4
std/lua/Coroutine.hx

@@ -26,21 +26,77 @@ import haxe.Constraints.Function;
 import haxe.extern.Rest;
 
 /**
-  Externs for native Lua coroutines.
- **/
+	Externs for native Lua coroutines.
+**/
 @:native("_G.coroutine")
 extern class Coroutine {
+	/**
+		Creates a new coroutine, with body `f`. `f` must be a Lua function. 
+	**/
 	public static function create(f : Function)  : Thread;
+
+	/**
+		Returns the status of coroutine.
+	**/
 	public static function status(c : Coroutine) : ThreadState;
+
+	/**
+		Starts or continues the execution of coroutine. 
+		The first time you resume a coroutine, it starts running its body.
+		The values `args` are passed as the arguments to the body function.
+		If the coroutine has yielded, `resume` restarts it; 
+		the values `args` are passed as the results from the yield.
+
+		If the coroutine runs without any errors, `resume` returns `true` plus any 
+		values passed to `yield` (if the coroutine yields) or any values returned 
+		by the body function (if the coroutine terminates). If there is any error, 
+		`resume` returns `false` plus the error message.
+	**/
 	public static function resume(c : Coroutine, args : Rest<Dynamic>) : Dynamic;
+
+	/**
+		Suspends the execution of the calling coroutine. 
+		The coroutine cannot be running a C function, a metamethod, or an iterator.
+		Any arguments to `yield` are passed as extra results to `resume`.
+	**/
 	public static function yield(args : Rest<Dynamic>) : Dynamic;
+
+	/**
+		Creates a new coroutine, with body `f`.
+		Returns a function that resumes the coroutine each time it is called. 
+		Any arguments passed to the function behave as the extra arguments to `resume`. 
+		Returns the same values returned by `resume`, except the first boolean. 
+		In case of error, propagates the error.
+	**/
 	public static function wrap(f : Function) : Thread;
 }
 
+/**
+	A enumerator that describes the output of `Coroutine.status()`.
+**/
 @:enum
 abstract ThreadState(String) {
+	/**
+		If the coroutine is suspended in a call to yield, or if it has not started 
+		running yet.
+	**/
 	var Suspended = "suspended";
-	var Running   = "running";
-	var Dead      = "dead";
+
+	/**
+		If the coroutine is running.
+	**/
+	var Running = "running";
+
+	/**
+		If the coroutine is active but not running. That is, it has resumed another 
+		coroutine.
+	**/
+	var Normal = "normal";
+
+	/**
+		If the coroutine has finished its body function or if it has stopped with 
+		an error.
+	**/
+	var Dead = "dead";
 }
 

+ 90 - 0
std/lua/Debug.hx

@@ -30,24 +30,114 @@ import lua.Table.AnyTable;
 
 @:native("debug")
 extern class Debug {
+	/**
+		This function returns the name and the value of the local variable with 
+		index local of the function at level level of the stack.
+	**/
 	public static function getlocal(stackLevel : Int, idx : Int) : Dynamic;
+
+	/**
+		This function assigns the value value to the local variable with index 
+		local of the function at level level of the stack. 
+		Call `getinfo` to check whether the level is valid. 
+	**/
 	public static function setlocal(stackLevel : Int, varName: String, value: Dynamic) : Void;
+
+	/**
+		Returns a table with information about a function. 
+	**/
 	public static function getinfo(stackLevel  : Int) : DebugInfo;
+
+	/**
+		Sets the given function as a hook. 
+		When called without arguments, `Debug.sethook` turns off the hook.
+	**/
 	public static function sethook(?fun : Function, ?monitor : String) : Void;
+
+	/**
+		Enters an interactive mode with the user, running each string that the user enters. 
+		Using simple commands and other debug facilities, the user can inspect 
+		global and local variables, change their values, evaluate expressions, 
+		and so on. A line containing only the word `cont` finishes this function, 
+		so that the caller continues its execution.
+
+		Note that commands for `Debug.debug` are not lexically nested within any 
+		function, and so have no direct access to local variables.
+	**/
 	public static function debug() : Void;
+
+	/**
+		Returns the current hook settings of the thread, as three values: 
+		the current hook function, the current hook mask, and the current hook count 
+		(as set by the `Debug.sethook` function).
+	**/
 	public static function gethook(thread : Coroutine) : Function;
+
+	/**
+		Returns the registry table.
+	**/
 	public static function getregistry() : AnyTable;
+
+	/**
+		Returns the metatable of the given `value` or `null` if it does not have a metatable.
+	**/
 	public static function getmetatable(value : AnyTable) : AnyTable;
+
+	/**
+		Sets the metatable for the given `value` to the given `table` (can be `null`).
+	**/
 	public static function setmetatable(value : AnyTable, table : AnyTable) : Void;
+
+	/**
+		This function returns the name and the value of the upvalue with index `up` 
+		of the function `f`. The function returns `null` if there is no upvalue with 
+		the given index.
+	**/
 	public static function getupvalue(f : Function, up : Int) : Dynamic;
+
+	/**
+		This function assigns the value value to the upvalue with index up of
+		the function `f`. The function returns `null` if there is no upvalue with
+		the given index. Otherwise, it returns the name of the upvalue.
+	**/
 	public static function setupvalue(f : Function, up : Int, val : Dynamic) : Void;
+
+	/**
+		Returns the Lua value associated to `val`. 
+		If `val` is not a `UserData`, returns `null`.
+	**/
 	public static function getuservalue(val : Dynamic) : Dynamic;
+
+	/**
+		Sets the given value as the Lua value associated to the given udata. 
+		`udata` must be a full `UserData`.
+	**/
 	public static function setuservalue(udata : Dynamic, val : Dynamic) : Void;
+
+	/**
+		Returns a string with a traceback of the call stack. 
+		@param message (optional) is appended at the beginning of the traceback.
+		@param level (optional) tells at which level to start the traceback. 
+		       default is `1`, the function calling traceback.
+	**/
 	public static function traceback(?thread : Coroutine, ?message : String, ?level : Int) : String;
+
+	/**
+		Returns a unique identifier (as a light userdata) for the upvalue numbered 
+		`n` from the given function `f`.
+	**/
 	public static function upvalueid(f : Function, n : Int) : Dynamic;
+
+	/**
+		Make the `n1`-th upvalue of the Lua closure `f1` refer to the `n2`-th 
+		upvalue of the Lua closure `f2`.
+	**/
 	public static function upvaluejoin(f1 : Function, n1 : Int, f2 : Function, n2 : Int) : Void;
 }
 
+/**
+	A enumerator that describes the output of `Debug.getinfo()`.
+**/
 typedef DebugInfo = { 
 	currentline     : Int,
 	func            : Function,

+ 66 - 0
std/lua/Io.hx

@@ -22,34 +22,100 @@
 package lua;
 import haxe.extern.Rest;
 
+/**
+		Input and Output Facilities
+**/
 @:native("_G.io")
 extern class Io {
 	public static var stdin  : FileHandle;
 	public static var stderr : FileHandle;
 	public static var stdout : FileHandle;
 
+	/**
+		Function to close regular files.
+	**/
 	public static function close(?file : FileHandle) : Void;
+
+	/**
+		Saves any written data to file.
+	**/
 	public static function flush() : Void;
 
+	/**
+		When called with a file name, it opens the named file (in text mode),
+		and sets its handle as the default input file. When called with a file handle,
+		it simply sets this file handle as the default input file.
+		When called without parameters, it returns the current default input file.
+
+		In case of errors this function raises the error, instead of returning an
+		error code.
+	**/
 	@:overload(   function      (file : String)     : Void {})
 	public static function input(file : FileHandle) : Void;
 
+	/**
+		Opens the given file name in read mode and returns an iterator function that, 
+		each time it is called, returns a new line from the file. 
+	**/
 	public static function lines(?file : String) : NativeIterator<String>;
 
+	/**
+		This function opens a file, in the mode specified in the string mode.
+		It returns a new file handle, or, in case of errors, `null` plus an error message.
+		
+		The mode string can be any of the following:
+		
+		 * `"r"`: read mode (the default)
+		 * `"w"`: write mode
+		 * `"a"`: append mode
+		 * `"r+"`: update mode, all previous data is preserved
+		 * `"w+"`: update mode, all previous data is erased
+		 * `"a+"`: append update mode, previous data is preserved, writing is only 
+		    allowed at the end of file
+		
+		The mode string can also have a `b` at the end, which is needed in some systems 
+		to open the file in binary mode. This string is exactly what is used in the 
+		standard C function fopen.
+	**/
 	public static function open (filename : String, ?mode : String) : FileHandle;
+
+	/**
+		Starts program `command` in a separated process and returns a file handle that 
+		you can use to read data from this program (if mode is `"r"`, the default) 
+		or to write data to this program (if mode is `"w"`).
+		
+		This function is system dependent and is not available on all platforms.
+	**/
 	public static function popen(command  : String, ?mode : String) : FileHandle;
 
 	@:overload(   function     (?count    : Int)    : String {})
 	public static function read(?filename : String) : String;
 
+	/**
+		Writes the value of each of its arguments to the file. The arguments must 
+		be strings or numbers. 
+		To write other values, use `Lua.tostring` or `NativeStringTools.format`
+		before write.
+	**/
 	public static function write(v : Rest<String>) : Void;
 
 	public static function output(?file : String) : FileHandle;
 
+	/**
+		Returns a handle for a temporary file. This file is opened in update mode
+		and it is automatically removed when the program ends.
+	**/
 	public static function tmpfile() : FileHandle;
+
+	/**
+		Checks whether `obj` is a valid file handle. 
+	**/
 	public static function type(obj : FileHandle) : IoType;
 }
 
+/**
+	A enumerator that describes the output of `Io.type()`.
+**/
 @:enum
 abstract IoType(String) {
 	var File = "file";

+ 4 - 2
std/lua/Lib.hx

@@ -30,7 +30,9 @@ import lua.NativeStringTools;
 	and vice-versa.
 **/
 class Lib {
-
+	/**
+		Print the specified value on the default output followed by a newline character.
+	**/
 	public static inline function println( v : Dynamic ) : Void {
 		Lua.print(Std.string(v));
 	}
@@ -67,8 +69,8 @@ class Lib {
 		}
 		return ret;
 	}
+
 	public inline static function isShellAvailable() : Bool {
 		return Os.execute();
 	}
-
 }

+ 140 - 3
std/lua/Lua.hx

@@ -4,34 +4,171 @@ import haxe.Constraints.Function;
 import haxe.extern.Rest;
 
 /**
-  These are all global static methods within lua
+  These are all global static methods within Lua.
  **/
 
 @:native("_G")
 extern class Lua {
+	/**
+		A global variable that holds a string containing the current interpreter 
+		version.
+	**/
 	public static var _VERSION : String;
+
 	public static var arg : Table<Int, String>;
+
+	/**
+		Pushes onto the stack the metatable in the registry.
+	**/
 	public static function getmetatable(tbl:Table<Dynamic,Dynamic>): Table<Dynamic,Dynamic>;
+
+	/**
+		Pops a table from the stack and sets it as the new metatable for the value 
+		at the given acceptable index.
+	**/
 	public static function setmetatable(tbl:Table<Dynamic,Dynamic>, mtbl: Table<Dynamic, Dynamic>): Void;
+
+	/**
+		Pops a table from the stack and sets it as the new environment for the value 
+		at the given index. If the value at the given index is neither a function nor 
+		a thread nor a userdata, lua_setfenv returns `0`. 
+		Otherwise it returns `1`.
+	**/
 	public static function setfenv(i:Int , tbl:Table<Dynamic, Dynamic>): Void;
+
+	/**
+		Allows a program to traverse all fields of a table. 
+		Its first argument is a table and its second argument is an index in this 
+		table. `next` returns the next index of the table and its associated value. 
+		When `i` is `null`, `next` returns an initial index and its associated value.
+		When called with the last index, or with `null` in an empty table, `next`
+		returns `null`.  In particular, you can use `next(t)` to check whether a 
+		table is empty.
+
+		The order in which the indices are enumerated is not specified, even for 
+		numeric indices. (To traverse a table in numeric order, use a numerical for 
+		or the `ipairs` function).
+
+		The behavior of next is undefined if, during the traversal, any value 
+		to a non-existent field in the table is assigned. Existing fields may 
+		however be modified. In particular, existing fields may be cleared.
+	**/
 	public static function next<T>(k:Table<Dynamic, T>, ?i : Null<Int>): T;
+
+	/**
+		Receives an argument of any type and converts it to a string in a reasonable 
+		format. 
+		
+		For complete control of how numbers are converted, use`NativeStringTools.format`.
+	**/
 	public static function tostring(v:Dynamic): String;
+
 	public static function ipairs<T>(t:Table<Int,T>): Void->T;
+
 	public static function pairs<A,B>(t:Table<A,B>): Void->A;
+
+	/**
+		Converts the Lua value at the given acceptable base to `Int`. 
+		The Lua value must be a number or a string convertible to a number, 
+		otherwise `tonumber` returns `0`.
+	**/
 	public static function tonumber(str:String, ?base:Int): Int;
+
+	/**
+		Returns the Lua type of its only argument as a string. 
+		The possible results of this function are:
+		
+		 * `"nil"` (a string, not the Lua value nil),
+		 * `"number"`
+		 * `"string"`
+		 * `"boolean"`
+		 * `"table"` 
+		 * `"function"` 
+		 * `"thread"`
+		 * `"userdata"`
+	**/
 	public static function type(v:Dynamic) : String;
+
+	/**
+		Receives any number of arguments, and prints their values to stdout, 
+		using the tostring function to convert them to strings. 
+		`print` is not intended for formatted output, but only as a quick way to show 
+		a value, typically for debugging. 
+		
+		For complete control of how numbers are converted, use `NativeStringTools.format`.
+	**/
 	public static function print(v:Dynamic) : Void;
+
+	/**
+		If `n` is a number, returns all arguments after argument number `n`.
+		Otherwise, `n` must be the string `"#"`, and select returns the total 
+		number of extra arguments it received.
+	**/
 	public static function select(n:Dynamic, rest:Rest<Dynamic>) : Dynamic;
+
+	/**
+		Gets the real value of `table[index]`, without invoking any metamethod. 
+	**/
 	public static function rawget<K,V>(t:Table<K,V>, k:K) : V;
+
+	/**
+		Sets the real value of `table[index]` to value, without invoking any metamethod. 
+	**/
 	public static function rawset<K,V>(t:Table<K,V>, k:K, v:V) : Void;
+
+	/**
+		This function is a generic interface to the garbage collector. 
+		It performs different functions according to its first argument.
+	**/
 	public static function collectgarbage(opt:CollectGarbageOption, ?arg:Int) : Int;
+
+	/**
+		Issues an error when the value of its argument `v` is `false` (i.e., `null`
+		or `false`) otherwise, returns all its arguments. message is an error message.
+		when absent, it defaults to "assertion failed!"
+	**/
 	public static function assert<T>(v:T, ?message:String) : T;
+	
+	/**
+		Loads and runs the given file. 
+	**/
 	public static function dofile(filename:String) : Void;
+
+	/**
+		Generates a Lua error. The error message (which can actually be a Lua value 
+		of any type) must be on the stack top. This function does a long jump, 
+		and therefore never returns.
+	**/
 	public static function error(message:String, ?level:Int) : Void;
+
+	/**
+		Calls a function in protected mode.
+	**/
 	public static function pcall(f:Function, rest:Rest<Dynamic>) : Bool;
+
+	/**
+		Returns `true` if the two values in acceptable indices `v1` and `v2` are 
+		primitively equal (that is, without calling metamethods). 
+		Otherwise returns `false`. 
+		Also returns `false` if any of the indices are non valid.
+	**/
 	public static function rawequal(v1:Dynamic, v2:Dynamic) : Bool;
+
+	/**
+		This function is similar to pcall, except that you can set a new error 
+		handler.
+	**/
 	public static function xpcall(f:Function, msgh:Function, rest:Rest<Dynamic> ) : Bool;
+
+	/**
+		Loads the chunk from file filename or from the standard input if no filename 
+		is given.
+	**/
 	public static function loadfile(filename:String) : Void;
+
+	/**
+		Loads the chunk from given string.
+	**/
 	public static function loadstring(code:String) : Void;
 
 	private static function __init__() : Void {
@@ -41,8 +178,8 @@ extern class Lua {
 }
 
 /**
-  Enum for describing garbage collection options
-  */
+	Enum for describing garbage collection options
+**/
 @:enum
 abstract CollectGarbageOption(String) {
 	var Stop = "stop";

+ 102 - 4
std/lua/NativeStringTools.hx

@@ -1,31 +1,129 @@
 package lua;
 /**
-  These are all externs for the base Lua "string" class, which functions 
-  as an additional set of string tools.
+	These are all externs for the base Lua "string" class, which functions 
+	as an additional set of string tools.
 
-  Note that all relevant indexes are "1" based.
- **/
+	Note that all relevant indexes are "1" based.
+**/
 @:native("_G.string")
 extern class NativeStringTools {
+	/**
+		Receives a string and returns its length. The empty string `""` has 
+		length `0`. Embedded zeros are counted, so `"a\000bc\000"` has length `5`.
+	**/
 	public static function len(str : String): Int;
+
+	/**
+		Receives zero or more integers. Returns a string with length equal to the 
+		number of arguments, in which each character has the internal numerical 
+		code equal to its corresponding argument.
+		Note that numerical codes are not necessarily portable across platforms.
+	**/
 	public static function char(codes: haxe.extern.Rest<Int>): String;
+
+	/**
+		Returns the substring of `str` that starts at `start` and continues until `end`; 
+		`start` and `end` can be negative. If `end` is absent, then it is assumed to be 
+		equal to `-1` (which is the same as the string length). 
+		In particular, the call `sub(str,1,end)` returns a prefix of `str` 
+		with length `end`, and `sub(str, -end)` returns a suffix of `str` with 
+		length `start`.
+	**/
 	public static function sub(str : String, start : Int, ?end : Int): String;
+
+	/**
+		Returns the character code at position `index` of `str`.
+	**/
 	public static function charCodeAt(str : String, index : Int): Int;
+
+	/**
+		Looks for the first match of pattern in the string `str`. 
+		If it finds a match, then `find` returns the indices of `str` where this 
+		occurrence starts and ends.
+		
+		@param target If the target has captures, then in a successful match the 
+		       captured values are also returned, after the two indices.
+		@param start specifies where to start the search; its default value is `1`
+		       and can be negative. 
+		@param plain turns off the pattern matching facilities, so the function does 
+		       a plain "find substring" operation, with no characters in pattern 
+		       being considered "magic". Note that if plain is given, then `start` must be given as well.
+	**/
 	public static function find(str : String, target : String, ?start : Int, ?plain : Bool): Int;
+
+	/**
+		Returns the internal numerical codes of the characters `str[index]`.
+		Note that numerical codes are not necessarily portable across platforms.
+	**/
 	public static function byte(str : String, ?index : Int) : Int;
+
+	/**
+		Returns a formatted version of its variable number of arguments following 
+		the description given in its first argument (which must be a string). 
+		The format string follows the same rules as the printf family of standard C 
+		functions. The only differences are that the options/modifiers 
+		`*`, `l`, `L`, `n`, `p`, and `h` are not supported and that there is an 
+		extra option, `q`. The `q` option formats a string in a form suitable to be
+		safely read back by the Lua interpreter: the string is written between 
+		double quotes, and all double quotes, newlines, embedded zeros, 
+		and backslashes in the string are correctly escaped when written.
+		For instance, the call
+   `string.format('%q', 'a string with "quotes" and \n new line')`
+		will produce the string:
+		`"a string with \"quotes\" and \
+      new line"`
+		
+		The options `c`, `d` `E`, `e`, `f`, `g`, `G`, `i`, `o`, `u, `X-, and `x` all 
+		expect a number as argument, whereas `q` and `s` expect a string.
+		
+		This function does not accept string values containing embedded zeros, 
+		except as arguments to the `q` option.
+	**/
 	public static function format(str : String, ?e1 : Dynamic, ?e2 : Dynamic, ?e3 : Dynamic, ?e4 : Dynamic): String;
 
+	/**
+		
+	**/
 	@:overload(   function     (str : String, pattern : String, replace : String->Void,   ?n : Int): String {})
 	@:overload(   function     (str : String, pattern : String, replace : String->String, ?n : Int): String {})
 	public static function gsub(str : String, pattern : String, replace : String,		  ?n : Int): String;
 
+	/**
+		Returns an iterator function that, each time it is called, returns the next 
+		captures from pattern over string `str`. If `pattern` specifies no captures, 
+		then the whole match is produced in each call.
+	**/
 	@:overload(   function     (str : String, pattern : String, match : Void->String,   ?n : Int): String->Void {})
 	public static function gmatch(str : String, pattern : String): Void->String;
 
+	/**
+		Looks for the first match of pattern in the string s. If it finds one, 
+		then match returns the captures from the pattern; otherwise it returns `null`.
+		If pattern specifies no captures, then the whole match is returned.
+		The optional argument `n` specifies where to start the search; 
+		its default value is `1` and can be negative.
+	**/
 	public static function match(str : String, pattern : String, ?n : Int): String;
 
+	/**
+		Receives a string and returns a copy of this string with all lowercase 
+		letters changed to uppercase. All other characters are left unchanged. 
+		The definition of what a lowercase letter is depends on the current locale.
+	**/
 	public static function upper(str:String) : String;
+
+	/**
+		Receives a string and returns a copy of this string with all uppercase 
+		letters changed to lowercase. All other characters are left unchanged. 
+		The definition of what an uppercase letter is depends on the current locale.
+	**/
 	public static function lower(str:String) : String;
+
+	/**
+		Returns a string containing a binary representation of the given function,
+		so that a later loadstring on this string returns a copy of the function.
+		function must be a Lua function without upvalues.
+	**/
 	public static function dump(d:Dynamic) : Dynamic;
 }
 

+ 63 - 4
std/lua/Os.hx

@@ -1,30 +1,89 @@
 package lua;
 
+/**
+	Operating System Facilities.
+**/
 @:native("_G.os")
 extern class Os {
+	/**
+		Returns an approximation of the amount in seconds of CPU time used by the
+		program.
+	**/
 	public static function clock() : Float;
 
 	@:overload(   function     (format : String, time : Time) : DateType {})
 	@:overload(   function     (format : String) : DateType {})
 	public static function date() : DateType;
 
+	/**
+		Returns the number of seconds from time `t1` to time `t2`. 
+		In POSIX, Windows, and some other systems, this value is exactly `t2-t1`.
+	**/
 	public static function difftime(t2: Time, t1: Time) : Float;
 
 	// TODO: multi-return
+	/**
+		This function is equivalent to the C function system. It passes command to 
+		be executed by an operating system shell. It returns a status code,
+		which is system-dependent. If command is absent, then it returns 
+		nonzero if a shell is available and zero otherwise.
+	**/
 	public static function execute(?command:String) : Bool;
 
+	/**
+		Calls the C function exit, with an optional code, to terminate the host program. 
+		The default value for code is the success code.
+	**/
 	public static function exit(code: Int) : Int;
+
+	/**
+		Returns the value of the process environment variable `varname`, or `null` 
+		if the variable is not defined.
+	**/
 	public static function getenv(varname : String) : String;
+
+	/**
+		Deletes the file or directory with the given name.
+		Directories must be empty to be removed. 
+	**/
 	public static function remove(filename : String) : Void;
+
+	/**
+		Renames file or directory named `oldname` to `newname`.
+	**/
 	public static function rename(oldname : String, newname : String) : Void;
+
+	/**
+		Sets the current locale of the program.
+	**/
 	public static function setlocale(locale : String, ?category : LocaleCategory ) : String;
+
+	/**
+		Returns the current time when called without arguments, or a time 
+		representing the date and time specified by the given table. 
+
+		The returned value is a number, whose meaning depends on your system. 
+		In POSIX, Windows, and some other systems, this number counts the number 
+		of seconds since some given start time (the "epoch"). 
+		In other systems, the meaning is not specified, and the number returned
+		by time can be used only as an argument to date and difftime.
+	**/
 	public static function time(?arg : TimeParam) : Time;
+
+	/**
+		Returns a string with a file name that can be used for a temporary file. 
+		The file must be explicitly opened before its use and explicitly removed
+		when no longer needed.
+		
+		When possible, you may prefer to use `Io.tmpfile`, which automatically 
+		removes the file when the program ends.
+	**/
 	public static function tmpname() : String;
 }
 
 /**
-  A typedef that matches the date parameter time() will accept.
- **/
+	A typedef that matches the date parameter `Os.time()` will accept.
+**/
 typedef TimeParam = {
 	year   : Float,
 	month  : Float,
@@ -36,8 +95,8 @@ typedef TimeParam = {
 }
 
 /**
-  A typedef that describes the output of date().
- **/
+	A typedef that describes the output of `Os.date()`.
+**/
 typedef DateType = {
 	hour  : Int,
 	min   : Int,

+ 32 - 0
std/lua/Package.hx

@@ -26,13 +26,45 @@ package lua;
  **/
 @:native("_G.package")
 extern class Package {
+	/**
+		A string describing some compile-time configurations for packages. 
+	**/
 	public static var config : String;
+
+	/**
+		The path used by require to search for a Lua loader.
+	**/
 	public static var path : String;
+
+	/**
+		The path used by require to search for a C loader.
+	**/
 	public static var cpath : String;
+
+	/**
+		A table used by require to control which modules are already loaded. 
+	**/
 	public static var loaded : Table<String, Bool>;
+
+	/**
+		A table to store loaders for specific modules.
+	**/
 	public static var preload : Table<String, Bool>;
+
+	/**
+		A table used by require to control how to load modules.
+		Each entry in this table is a searcher function. 
+	**/
 	public static var searchers :Table<Int,Void->Null<String>>;
 
+	/**
+		Searches for the given `libname` in the given path `funcname`.
+		A path is a string containing a sequence of templates separated by semicolons. 
+	**/
 	public static function searchpath(name : String, path : String, ?sep : String, ?rep : String) : Null<String>;
+
+	/**
+		Dynamically links the host program with the C library `libname`.
+	**/
 	public static function loadlib(libname : String, funcname : String) : Void;
 }

+ 3 - 0
std/lua/Table.hx

@@ -1,5 +1,8 @@
 package lua;
 
+/**
+	This library provides generic functions for table manipulation. 
+**/
 @:native("_G.table") 
 extern class Table<A,B> implements ArrayAccess<B> implements Dynamic<B> {
 	@:overload(function<A,B>(table:Table<A,B>):Void{})

+ 0 - 1
std/lua/Thread.hx

@@ -27,5 +27,4 @@ package lua;
   The sole purpose of this extern is to provide a concrete type for 
   basic reflection purposes.
 **/
-
 class Thread {}