Some docs work
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,6 +20,7 @@ haxedoc.xml
|
|||||||
docs/api/*.xml
|
docs/api/*.xml
|
||||||
docs/api/xml
|
docs/api/xml
|
||||||
docs/api/pages*
|
docs/api/pages*
|
||||||
|
docs/api/dump
|
||||||
docs/.sass-cache
|
docs/.sass-cache
|
||||||
docs/_site
|
docs/_site
|
||||||
legacy/ndll/*/lime*
|
legacy/ndll/*/lime*
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
-swf-version 17.0
|
-swf-version 17.0
|
||||||
-D display
|
-D display
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
-D lime_opengl
|
-D lime_opengl
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
@@ -19,6 +20,7 @@ ImportAll
|
|||||||
-D lime-cffi
|
-D lime-cffi
|
||||||
-D windows
|
-D windows
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
--no-output
|
--no-output
|
||||||
@@ -32,6 +34,7 @@ ImportAll
|
|||||||
-D lime-cffi
|
-D lime-cffi
|
||||||
-D mac
|
-D mac
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
--no-output
|
--no-output
|
||||||
@@ -45,21 +48,22 @@ ImportAll
|
|||||||
-D lime-cffi
|
-D lime-cffi
|
||||||
-D linux
|
-D linux
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
--no-output
|
--no-output
|
||||||
|
|
||||||
--next
|
# --next
|
||||||
|
|
||||||
-xml xml/Neko.xml
|
# -xml xml/Neko.xml
|
||||||
-neko obj/docs
|
# -neko obj/docs
|
||||||
-D display
|
# -D display
|
||||||
-D native
|
# -D native
|
||||||
-D lime-cffi
|
# -D lime-cffi
|
||||||
-D doc_gen
|
# -D doc_gen
|
||||||
ImportAll
|
# ImportAll
|
||||||
-lib lime
|
# -lib lime
|
||||||
--no-output
|
# --no-output
|
||||||
|
|
||||||
--next
|
--next
|
||||||
|
|
||||||
@@ -70,6 +74,7 @@ ImportAll
|
|||||||
-D lime-cffi
|
-D lime-cffi
|
||||||
-D ios
|
-D ios
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
--no-output
|
--no-output
|
||||||
@@ -83,6 +88,7 @@ ImportAll
|
|||||||
-D lime-cffi
|
-D lime-cffi
|
||||||
-D android
|
-D android
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
--no-output
|
--no-output
|
||||||
@@ -129,6 +135,7 @@ ImportAll
|
|||||||
-D display
|
-D display
|
||||||
-D html5
|
-D html5
|
||||||
-D doc_gen
|
-D doc_gen
|
||||||
|
-D lime-doc-gen
|
||||||
-D lime_opengl
|
-D lime_opengl
|
||||||
ImportAll
|
ImportAll
|
||||||
-lib lime
|
-lib lime
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ import lime.ui.Window;
|
|||||||
import lime.ui.WindowAttributes;
|
import lime.ui.WindowAttributes;
|
||||||
import lime.utils.Preloader;
|
import lime.utils.Preloader;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Application class forms the foundation for most Lime projects.
|
||||||
|
* It is common to extend this class in a main class. It is then possible
|
||||||
|
* to override "on" functions in the class in order to handle standard events
|
||||||
|
* that are relevant.
|
||||||
|
*/
|
||||||
|
|
||||||
@:access(lime.ui.Window)
|
@:access(lime.ui.Window)
|
||||||
|
|
||||||
#if !lime_debug
|
#if !lime_debug
|
||||||
@@ -23,12 +31,6 @@ import lime.utils.Preloader;
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Application class forms the foundation for most Lime projects.
|
|
||||||
* It is common to extend this class in a main class. It is then possible
|
|
||||||
* to override "on" functions in the class in order to handle standard events
|
|
||||||
* that are relevant.
|
|
||||||
*/
|
|
||||||
class Application extends Module {
|
class Application extends Module {
|
||||||
|
|
||||||
|
|
||||||
@@ -52,6 +54,9 @@ class Application extends Module {
|
|||||||
*/
|
*/
|
||||||
public var onUpdate = new Event<Int->Void> ();
|
public var onUpdate = new Event<Int->Void> ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatched when a new window has been created by this application
|
||||||
|
**/
|
||||||
public var onCreateWindow = new Event<Window->Void> ();
|
public var onCreateWindow = new Event<Window->Void> ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
package lime.app;
|
package lime.app;
|
||||||
|
|
||||||
|
|
||||||
#if macro
|
/**
|
||||||
import haxe.macro.Context;
|
Event is a strictly-typed signals and slots implementation, used for
|
||||||
import haxe.macro.Expr;
|
core event dispatching.
|
||||||
import haxe.macro.Type;
|
|
||||||
using haxe.macro.Tools;
|
For example:
|
||||||
#end
|
|
||||||
|
```
|
||||||
|
var event = new Event<Int->Void> ();
|
||||||
|
event.add (function (value:Int):Void { trace (value); });
|
||||||
|
event.dispatch (100);
|
||||||
|
|
||||||
|
var event = new Event<Void->Void> ();
|
||||||
|
event.add (function () { trace ("callback"); });
|
||||||
|
event.dispatch ();
|
||||||
|
```
|
||||||
|
**/
|
||||||
|
|
||||||
#if (!macro && !display)
|
#if (!macro && !display)
|
||||||
@:genericBuild(lime._internal.macros.EventMacro.build())
|
@:genericBuild(lime._internal.macros.EventMacro.build())
|
||||||
@@ -21,6 +31,9 @@ using haxe.macro.Tools;
|
|||||||
class Event<T> {
|
class Event<T> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the event was canceled during the previous dispatch
|
||||||
|
**/
|
||||||
public var canceled (default, null):Bool;
|
public var canceled (default, null):Bool;
|
||||||
|
|
||||||
@:noCompletion @:dox(hide) public var __listeners:Array<T>;
|
@:noCompletion @:dox(hide) public var __listeners:Array<T>;
|
||||||
@@ -28,6 +41,9 @@ class Event<T> {
|
|||||||
@:noCompletion private var __priorities:Array<Int>;
|
@:noCompletion private var __priorities:Array<Int>;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Event instance
|
||||||
|
**/
|
||||||
public function new () {
|
public function new () {
|
||||||
|
|
||||||
#if !macro
|
#if !macro
|
||||||
@@ -40,6 +56,12 @@ class Event<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds a new event listener
|
||||||
|
@param listener A callback that matches the signature of the event
|
||||||
|
@param once Whether to receive an event dispatch only once, or each time it is fired
|
||||||
|
@param priority The priority for this listener, a higher priority will be dispatched sooner
|
||||||
|
**/
|
||||||
public function add (listener:T, once:Bool = false, priority:Int = 0):Void {
|
public function add (listener:T, once:Bool = false, priority:Int = 0):Void {
|
||||||
|
|
||||||
#if !macro
|
#if !macro
|
||||||
@@ -64,158 +86,9 @@ class Event<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if macro
|
/**
|
||||||
private static function build () {
|
Marks the event as canceled, and stops the current event dispatch
|
||||||
|
**/
|
||||||
var typeArgs;
|
|
||||||
var typeResult;
|
|
||||||
|
|
||||||
switch (Context.follow (Context.getLocalType ())) {
|
|
||||||
|
|
||||||
case TInst (_, [ Context.follow (_) => TFun (args, result) ]):
|
|
||||||
|
|
||||||
typeArgs = args;
|
|
||||||
typeResult = result;
|
|
||||||
|
|
||||||
case TInst (localType, _):
|
|
||||||
|
|
||||||
Context.fatalError ("Invalid number of type parameters for " + localType.toString (), Context.currentPos ());
|
|
||||||
return null;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
throw false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var typeParam = TFun (typeArgs, typeResult);
|
|
||||||
var typeString = "";
|
|
||||||
|
|
||||||
if (typeArgs.length == 0) {
|
|
||||||
|
|
||||||
typeString = "Void->";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
for (arg in typeArgs) {
|
|
||||||
|
|
||||||
typeString += arg.t.toString () + "->";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
typeString += typeResult.toString ();
|
|
||||||
typeString = StringTools.replace (typeString, "->", "_");
|
|
||||||
typeString = StringTools.replace (typeString, ".", "_");
|
|
||||||
typeString = StringTools.replace (typeString, "<", "_");
|
|
||||||
typeString = StringTools.replace (typeString, ">", "_");
|
|
||||||
|
|
||||||
var name = "_Event_" + typeString;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
Context.getType ("lime.app." + name);
|
|
||||||
|
|
||||||
} catch (e:Dynamic) {
|
|
||||||
|
|
||||||
var pos = Context.currentPos ();
|
|
||||||
var fields = Context.getBuildFields ();
|
|
||||||
|
|
||||||
var args:Array<FunctionArg> = [];
|
|
||||||
var argName, argNames = [];
|
|
||||||
|
|
||||||
for (i in 0...typeArgs.length) {
|
|
||||||
|
|
||||||
if (i == 0) {
|
|
||||||
|
|
||||||
argName = "a";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
argName = "a" + i;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
argNames.push (Context.parse (argName, pos));
|
|
||||||
args.push ({ name: argName, type: typeArgs[i].t.toComplexType () });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var dispatch = macro {
|
|
||||||
|
|
||||||
canceled = false;
|
|
||||||
|
|
||||||
var listeners = __listeners;
|
|
||||||
var repeat = __repeat;
|
|
||||||
var i = 0;
|
|
||||||
|
|
||||||
while (i < listeners.length) {
|
|
||||||
|
|
||||||
listeners[i] ($a{argNames});
|
|
||||||
|
|
||||||
if (!repeat[i]) {
|
|
||||||
|
|
||||||
this.remove (cast listeners[i]);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canceled) {
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 0;
|
|
||||||
var field;
|
|
||||||
|
|
||||||
while (i < fields.length) {
|
|
||||||
|
|
||||||
field = fields[i];
|
|
||||||
|
|
||||||
if (field.name == "__listeners" || field.name == "dispatch") {
|
|
||||||
|
|
||||||
fields.remove (field);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fields.push ( { name: "__listeners", access: [ APublic ], kind: FVar (TPath ({ pack: [], name: "Array", params: [ TPType (typeParam.toComplexType ()) ] })), pos: pos } );
|
|
||||||
fields.push ( { name: "dispatch", access: [ APublic ], kind: FFun ( { args: args, expr: dispatch, params: [], ret: macro :Void } ), pos: pos } );
|
|
||||||
|
|
||||||
Context.defineType ({
|
|
||||||
|
|
||||||
pos: pos,
|
|
||||||
pack: [ "lime", "app" ],
|
|
||||||
name: name,
|
|
||||||
kind: TDClass (),
|
|
||||||
fields: fields,
|
|
||||||
params: [ { name: "T" } ],
|
|
||||||
meta: [ { name: ":dox", params: [ macro hide ], pos: pos }, { name: ":noCompletion", pos: pos } ]
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return TPath ( { pack: [ "lime", "app" ], name: name, params: [ TPType (typeParam.toComplexType ()) ] } ).toType ();
|
|
||||||
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
|
|
||||||
|
|
||||||
public function cancel ():Void {
|
public function cancel ():Void {
|
||||||
|
|
||||||
canceled = true;
|
canceled = true;
|
||||||
@@ -223,6 +96,12 @@ class Event<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Dispatches a new event callback to all listeners. The signature for the
|
||||||
|
`dispatch` method depends upon the type of the `Event`. For example, an
|
||||||
|
`Event` of type `Int->Int->Void` will create a `dispatch` method that
|
||||||
|
takes two `Int` arguments, like `dispatch (1, 2);`
|
||||||
|
**/
|
||||||
public var dispatch:Dynamic;
|
public var dispatch:Dynamic;
|
||||||
|
|
||||||
//macro public function dispatch (ethis:Expr, args:Array<Expr>):Void {
|
//macro public function dispatch (ethis:Expr, args:Array<Expr>):Void {
|
||||||
@@ -254,6 +133,11 @@ class Event<T> {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks whether a callback is a listener to this event
|
||||||
|
@param listener A callback that matches the signature of the event
|
||||||
|
@return Whether the callback is a listener
|
||||||
|
**/
|
||||||
public function has (listener:T):Bool {
|
public function has (listener:T):Bool {
|
||||||
|
|
||||||
#if !macro
|
#if !macro
|
||||||
@@ -269,6 +153,10 @@ class Event<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Removes an event listener
|
||||||
|
@param listener A callback that matches the signature of the event
|
||||||
|
**/
|
||||||
public function remove (listener:T):Void {
|
public function remove (listener:T):Void {
|
||||||
|
|
||||||
#if !macro
|
#if !macro
|
||||||
|
|||||||
Reference in New Issue
Block a user