This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile with: haxe -main WebSocketTest.hx -js WebSocketTest.js | |
// Doing your imports like this makes it much easier to port with existing Javascript code. | |
import js.Browser.window; | |
import js.Browser.document; | |
import js.html.*; | |
class WebSocketTest | |
{ | |
static var wsUri = "ws://echo.websocket.org/"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys.db.Types; | |
using Lambda; | |
/** | |
* What this class shows: | |
* | |
* Using a custom serialiser for SPOD can reduce speeds by more than half. | |
* Have a build macro append a static array containing the names of the fields to serialise. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.ds.StringMap; | |
import haxe.web.Dispatch; | |
import haxe.web.Dispatch.DispatchError; | |
#if sys | |
import Sys.println; | |
import Sys.print; | |
#else | |
import haxe.Log.trace in println; | |
import haxe.Log.trace in print; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
class F | |
{ | |
macro public static function f(a : Expr, b : Int) : Expr | |
{ | |
// get the field name as a string, use Pattern Matching or tink macros probably... | |
var fieldName = switch (a.expr) { | |
case EConst(CIdent(name)): name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
import sys.FileSystem; | |
import sys.io.File; | |
import haxe.io.Path; | |
class BuildMacro | |
{ | |
static function build() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Expr; | |
import haxe.macro.Type; | |
import haxe.macro.Context; | |
class MacroTest | |
{ | |
macro public function build():Array<Field> | |
{ | |
trace ("Build macro"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Expr; | |
import haxe.macro.Context; | |
import neko.Lib; | |
class BuildInMacroTests { | |
public static function main() { | |
var s:MyModel = new MyModel(); | |
Formatter.__Output_Formatter( s ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArrayAccessTest { | |
static function main() { | |
var myArray:MyArray<Int> = [0,10,20]; | |
trace ( myArray[1] ); | |
trace ( myArray["one"] ); | |
trace ( myArray[["one","two","three"]] ); | |
} | |
} | |
abstract MyArray<T>(Array<T>) from Array<T> to Array<T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cast | |
{ | |
static function main() | |
{ | |
var array = [0,1,2,3]; | |
var list = Lambda.list( array ); | |
var map = [ "a"=>0, "b"=>1, "c"=>2 ]; | |
var stringMap:haxe.ds.StringMap<Int> = map; | |
var myAbstract:AbstractIterator<Int> = array; | |
var myAbstract2:AbstractIterator2<Int> = array; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sys.db; | |
@:coreApi class Mysql { | |
static var init = false; | |
/** | |
Opens a new MySQL connection on the specified path. | |
Note that you will need a MySQL JDBC driver. | |
"socket" option currently not supported |