Sync files
This commit is contained in:
@@ -36,6 +36,40 @@ enum StackItem {
|
|||||||
Get informations about the call stack.
|
Get informations about the call stack.
|
||||||
**/
|
**/
|
||||||
class CallStack {
|
class CallStack {
|
||||||
|
#if js
|
||||||
|
static var lastException:js.Error;
|
||||||
|
|
||||||
|
static function getStack(e:js.Error):Array<StackItem> {
|
||||||
|
if (e == null) return [];
|
||||||
|
// https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
||||||
|
var oldValue = (untyped Error).prepareStackTrace;
|
||||||
|
(untyped Error).prepareStackTrace = function (error, callsites :Array<Dynamic>) {
|
||||||
|
var stack = [];
|
||||||
|
for (site in callsites) {
|
||||||
|
if (wrapCallSite != null) site = wrapCallSite(site);
|
||||||
|
var method = null;
|
||||||
|
var fullName :String = site.getFunctionName();
|
||||||
|
if (fullName != null) {
|
||||||
|
var idx = fullName.lastIndexOf(".");
|
||||||
|
if (idx >= 0) {
|
||||||
|
var className = fullName.substr(0, idx);
|
||||||
|
var methodName = fullName.substr(idx+1);
|
||||||
|
method = Method(className, methodName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.push(FilePos(method, site.getFileName(), site.getLineNumber()));
|
||||||
|
}
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
var a = makeStack(e.stack);
|
||||||
|
(untyped Error).prepareStackTrace = oldValue;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// support for source-map-support module
|
||||||
|
@:noCompletion
|
||||||
|
public static var wrapCallSite:Dynamic->Dynamic;
|
||||||
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the call stack elements, or an empty array if not available.
|
Return the call stack elements, or an empty array if not available.
|
||||||
@@ -45,45 +79,24 @@ class CallStack {
|
|||||||
var a = makeStack(untyped __dollar__callstack());
|
var a = makeStack(untyped __dollar__callstack());
|
||||||
a.shift(); // remove Stack.callStack()
|
a.shift(); // remove Stack.callStack()
|
||||||
return a;
|
return a;
|
||||||
#elseif flash9
|
#elseif flash
|
||||||
var a = makeStack( new flash.errors.Error().getStackTrace() );
|
var a = makeStack( new flash.errors.Error().getStackTrace() );
|
||||||
a.shift(); // remove Stack.callStack()
|
a.shift(); // remove Stack.callStack()
|
||||||
return a;
|
return a;
|
||||||
#elseif flash
|
|
||||||
return makeStack("$s");
|
|
||||||
#elseif php
|
#elseif php
|
||||||
return makeStack("%s");
|
return makeStack("%s");
|
||||||
#elseif cpp
|
#elseif cpp
|
||||||
var s:Array<String> = untyped __global__.__hxcpp_get_call_stack(true);
|
var s:Array<String> = untyped __global__.__hxcpp_get_call_stack(true);
|
||||||
return makeStack(s);
|
return makeStack(s);
|
||||||
#elseif js
|
#elseif js
|
||||||
// https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
|
||||||
var oldValue = (untyped Error).prepareStackTrace;
|
|
||||||
(untyped Error).prepareStackTrace = function (error, callsites :Array<Dynamic>) {
|
|
||||||
var stack = [];
|
|
||||||
for (site in callsites) {
|
|
||||||
var method = null;
|
|
||||||
var fullName :String = site.getFunctionName();
|
|
||||||
if (fullName != null) {
|
|
||||||
var idx = fullName.lastIndexOf(".");
|
|
||||||
if (idx >= 0) {
|
|
||||||
var className = fullName.substr(0, idx);
|
|
||||||
var methodName = fullName.substr(idx+1);
|
|
||||||
method = Method(className, methodName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stack.push(FilePos(method, site.getFileName(), site.getLineNumber()));
|
|
||||||
}
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
throw untyped __new__("Error");
|
throw new js.Error();
|
||||||
} catch( e : Dynamic ) {
|
} catch( e : Dynamic ) {
|
||||||
var a = makeStack(e.stack);
|
var a = getStack(e);
|
||||||
if( a != null ) a.shift(); // remove Stack.callStack()
|
a.shift(); // remove Stack.callStack()
|
||||||
(untyped Error).prepareStackTrace = oldValue;
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elseif java
|
#elseif java
|
||||||
var stack = [];
|
var stack = [];
|
||||||
for ( el in java.lang.Thread.currentThread().getStackTrace() ) {
|
for ( el in java.lang.Thread.currentThread().getStackTrace() ) {
|
||||||
@@ -129,7 +142,7 @@ class CallStack {
|
|||||||
return makeStack(untyped __dollar__excstack());
|
return makeStack(untyped __dollar__excstack());
|
||||||
#elseif as3
|
#elseif as3
|
||||||
return new Array();
|
return new Array();
|
||||||
#elseif flash9
|
#elseif flash
|
||||||
var err : flash.errors.Error = untyped flash.Boot.lastError;
|
var err : flash.errors.Error = untyped flash.Boot.lastError;
|
||||||
if( err == null ) return new Array();
|
if( err == null ) return new Array();
|
||||||
var a = makeStack( err.getStackTrace() );
|
var a = makeStack( err.getStackTrace() );
|
||||||
@@ -143,8 +156,6 @@ class CallStack {
|
|||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
#elseif flash
|
|
||||||
return makeStack("$e");
|
|
||||||
#elseif php
|
#elseif php
|
||||||
return makeStack("%e");
|
return makeStack("%e");
|
||||||
#elseif cpp
|
#elseif cpp
|
||||||
@@ -182,6 +193,8 @@ class CallStack {
|
|||||||
stack.push(FilePos(null, elem._1, elem._2));
|
stack.push(FilePos(null, elem._1, elem._2));
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
|
#elseif js
|
||||||
|
return untyped __define_feature__("haxe.CallStack.exceptionStack", getStack(lastException));
|
||||||
#else
|
#else
|
||||||
return []; // Unsupported
|
return []; // Unsupported
|
||||||
#end
|
#end
|
||||||
@@ -245,7 +258,7 @@ class CallStack {
|
|||||||
a.unshift(FilePos(null,new String(untyped x[0]),untyped x[1]));
|
a.unshift(FilePos(null,new String(untyped x[0]),untyped x[1]));
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
#elseif flash9
|
#elseif flash
|
||||||
var a = new Array();
|
var a = new Array();
|
||||||
var r = ~/at ([^\/]+?)\$?(\/[^\(]+)?\(\)(\[(.*?):([0-9]+)\])?/;
|
var r = ~/at ([^\/]+?)\$?(\/[^\(]+)?\(\)(\[(.*?):([0-9]+)\])?/;
|
||||||
var rlambda = ~/^MethodInfo-([0-9]+)$/g;
|
var rlambda = ~/^MethodInfo-([0-9]+)$/g;
|
||||||
@@ -266,14 +279,6 @@ class CallStack {
|
|||||||
s = r.matchedRight();
|
s = r.matchedRight();
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
#elseif flash
|
|
||||||
var a : Array<String> = untyped __eval__(s);
|
|
||||||
var m = new Array();
|
|
||||||
for( i in 0...a.length - if(s == "$s") 2 else 0 ) {
|
|
||||||
var d = a[i].split("::");
|
|
||||||
m.unshift(Method(d[0],d[1]));
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
#elseif php
|
#elseif php
|
||||||
if (!untyped __call__("isset", __var__("GLOBALS", s)))
|
if (!untyped __call__("isset", __var__("GLOBALS", s)))
|
||||||
return [];
|
return [];
|
||||||
@@ -298,7 +303,9 @@ class CallStack {
|
|||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
#elseif js
|
#elseif js
|
||||||
if ((untyped __js__("typeof"))(s) == "string") {
|
if (s == null) {
|
||||||
|
return [];
|
||||||
|
} else if ((untyped __js__("typeof"))(s) == "string") {
|
||||||
// Return the raw lines in browsers that don't support prepareStackTrace
|
// Return the raw lines in browsers that don't support prepareStackTrace
|
||||||
var stack : Array<String> = s.split("\n");
|
var stack : Array<String> = s.split("\n");
|
||||||
if( stack[0] == "Error" ) stack.shift();
|
if( stack[0] == "Error" ) stack.shift();
|
||||||
@@ -312,7 +319,7 @@ class CallStack {
|
|||||||
var line = Std.parseInt(rie10.matched(3));
|
var line = Std.parseInt(rie10.matched(3));
|
||||||
m.push(FilePos( meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."),meth), file, line ));
|
m.push(FilePos( meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."),meth), file, line ));
|
||||||
} else
|
} else
|
||||||
m.push(Module(line)); // A little weird, but better than nothing
|
m.push(Module(StringTools.trim(line))); // A little weird, but better than nothing
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -62,12 +62,9 @@ class Timer {
|
|||||||
The accuracy of this may be platform-dependent.
|
The accuracy of this may be platform-dependent.
|
||||||
**/
|
**/
|
||||||
public function new( time_ms : Int ){
|
public function new( time_ms : Int ){
|
||||||
#if flash9
|
#if flash
|
||||||
var me = this;
|
var me = this;
|
||||||
id = untyped __global__["flash.utils.setInterval"](function() { me.run(); },time_ms);
|
id = untyped __global__["flash.utils.setInterval"](function() { me.run(); },time_ms);
|
||||||
#elseif flash
|
|
||||||
var me = this;
|
|
||||||
id = untyped _global["setInterval"](function() { me.run(); },time_ms);
|
|
||||||
#elseif js
|
#elseif js
|
||||||
var me = this;
|
var me = this;
|
||||||
id = untyped setInterval(function() me.run(),time_ms);
|
id = untyped setInterval(function() me.run(),time_ms);
|
||||||
@@ -89,10 +86,8 @@ class Timer {
|
|||||||
#if (flash || js)
|
#if (flash || js)
|
||||||
if( id == null )
|
if( id == null )
|
||||||
return;
|
return;
|
||||||
#if flash9
|
#if flash
|
||||||
untyped __global__["flash.utils.clearInterval"](id);
|
untyped __global__["flash.utils.clearInterval"](id);
|
||||||
#elseif flash
|
|
||||||
untyped _global["clearInterval"](id);
|
|
||||||
#elseif js
|
#elseif js
|
||||||
untyped clearInterval(id);
|
untyped clearInterval(id);
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -21,12 +21,18 @@
|
|||||||
*/
|
*/
|
||||||
package haxe.crypto;
|
package haxe.crypto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Hash methods for Hmac calculation.
|
||||||
|
*/
|
||||||
enum HashMethod {
|
enum HashMethod {
|
||||||
MD5;
|
MD5;
|
||||||
SHA1;
|
SHA1;
|
||||||
SHA256;
|
SHA256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Calculates a Hmac of the given Bytes using a HashMethod.
|
||||||
|
*/
|
||||||
class Hmac {
|
class Hmac {
|
||||||
|
|
||||||
var method : HashMethod;
|
var method : HashMethod;
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
package haxe.crypto;
|
package haxe.crypto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates a Sha256 of a String.
|
||||||
|
*/
|
||||||
class Sha256 {
|
class Sha256 {
|
||||||
|
|
||||||
public static function encode( s:String ) : String {
|
public static function encode( s:String ) : String {
|
||||||
|
|||||||
@@ -246,12 +246,9 @@ class Boot {
|
|||||||
return __nativeClassName(o) != null;
|
return __nativeClassName(o) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve native JS class (with window or global):
|
// resolve native JS class in the global scope:
|
||||||
static function __resolveNativeClass(name:String) untyped {
|
static function __resolveNativeClass(name:String) untyped {
|
||||||
if (__js__("typeof window") != "undefined")
|
return untyped Function('return typeof $name != "undefined" ? $name : null')();
|
||||||
return window[name];
|
|
||||||
else
|
|
||||||
return global[name];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user