Skip to content

Commit

Permalink
typedef jQuery.haxe.Rest<T> = haxe.extern.Rest<T>;
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli committed Apr 10, 2015
1 parent aa73384 commit 69e1c9d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion jQuery/JQuery.hx
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ package jQuery;
**/
@:overload
@:jQueryVersion({ added : "1.7" })
public function on(events:String, ?selector:String, ?data:Dynamic, handler:jQuery.haxe.Either<jQuery.Event -> Void, jQuery.Event -> haxe.extern.Rest<Dynamic> -> Void>):jQuery.JQuery;
public function on(events:String, ?selector:String, ?data:Dynamic, handler:jQuery.haxe.Either<jQuery.Event -> Void, jQuery.Event -> jQuery.haxe.Rest<Dynamic> -> Void>):jQuery.JQuery;
/**
Get the current computed width for the first element in the set of matched elements, including padding and border.
**/
Expand Down
2 changes: 1 addition & 1 deletion jQuery/JQueryStatic.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ package jQuery;
Provides a way to execute callback functions based on one or more objects, usually <a href="/category/deferred-object/">Deferred</a> objects that represent asynchronous events.
**/
@:jQueryVersion({ added : "1.5" })
static public function when(deferreds:haxe.extern.Rest<jQuery.Deferred>):jQuery.Promise;
static public function when(deferreds:jQuery.haxe.Rest<jQuery.Deferred>):jQuery.Promise;
/**
A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
**/
Expand Down
21 changes: 0 additions & 21 deletions jQuery/haxe/Config.hx
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,6 @@ class Config {
static public function setAllowDeprecated(v:Bool):Bool {
return allowDeprecated = v;
}

/**
If `haxe.extern.Rest` is not defined (when haxe <= 3.1.3), `typedef haxe.extern.Rest<T> = T;`.
**/
static var Rest = try {
Context.getType("haxe.extern.Rest");
} catch(e:Dynamic) {
Context.onTypeNotFound(function(s:String) {
return if (s == "haxe.extern.Rest") {
{
pack: ["haxe.extern"],
name: "Rest",
pos: Context.currentPos(),
params: [{name:"T"}],
kind: TDAlias(macro:T),
fields: []
}
} else null;
});
Context.getType("haxe.extern.Rest");
}

/**
Build function of all generated extern.
Expand Down
8 changes: 8 additions & 0 deletions jQuery/haxe/Rest.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package jQuery.haxe;

#if (haxe_ver >= 3.2)
typedef Rest<T> = haxe.extern.Rest<T>;
#else
//It is not accurate but let it be...
typedef Rest<T> = T;
#end
6 changes: 3 additions & 3 deletions jQuery/haxe/gen/CoreExternGenerator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class CoreExternGenerator {
case TFunction(args, ret):
var lastArg = args[args.length-1];
switch (lastArg) {
case macro:haxe.extern.Rest<$restType>:
case macro:jQuery.haxe.Rest<$restType>:
ct = either([
TFunction(args.slice(0, args.length-1), ret),
ct,
Expand Down Expand Up @@ -121,7 +121,7 @@ class CoreExternGenerator {
var _tag = tag.x.copy();
_tag.remove("rest");
return toComplexType(type, new Fast(_tag))
.map(function(ct) return macro:haxe.extern.Rest<$ct>);
.map(function(ct) return macro:jQuery.haxe.Rest<$ct>);
}

var simple = type == null ? [macro:Dynamic] : switch(type) {
Expand Down Expand Up @@ -272,7 +272,7 @@ class CoreExternGenerator {
[macro:Array<js.html.Node>];

case [_, "deferreds", "Deferred"|"deferred"]:
[macro:haxe.extern.Rest<jQuery.Deferred>];
[macro:jQuery.haxe.Rest<jQuery.Deferred>];

case [_, _, "Deferred"|"deferred"]:
[macro:jQuery.Deferred];
Expand Down

0 comments on commit 69e1c9d

Please sign in to comment.