Skip to content

Instantly share code, notes, and snippets.

@RealyUniqueName
RealyUniqueName / Json.hx
Last active February 10, 2022 15:45
Sample PHP externs for Haxe
//You can use any package name here.
//It's not required to match the namespace of php file.
package;
import php.NativeStructArray;
typedef EncodingOptions = {
?prettyPrint:Bool,
?enableJsonExprFinder:Bool,
}
@:native('\\phpmailerNamespace\\PHPMailer')
extern class PHPMailerNative
{
public function addAttachment( path : String, name : String = "", encoding : String = "base64", type : String = "", disposition : String = "attachment" ) : Bool
}
class PHPMailer extends PHPMailerNative
{
override public function addAttachment( path : String, name : String = "", encoding : String = "base64", type : String = "", disposition : String = "attachment" ) : Bool
@RealyUniqueName
RealyUniqueName / Test.hx
Created August 13, 2016 03:17
New php generator for Haxe
package example;
import php7.Exception;
class TestSuper {
function new () {}
function superMethod () return [Std.random(2), Std.random(2)][Std.random(2)];
@RealyUniqueName
RealyUniqueName / KeyValueIterator.hx
Last active October 14, 2016 10:35
Key-value map iterator
class KeyValueIterator<K,V> {
var map:Map<K,V>;
var keys:Iterator<K>;
static public inline function pairs<K,V>(map:Map<K,V>) return new KeyValueIterator(map);
public inline function new(map:Map<K,V>) {
this.map = map;
this.keys = map.keys();
}
@RealyUniqueName
RealyUniqueName / Main.hx
Created February 15, 2016 18:23
Minimal slider example for StablexUI
package;
import flash.Lib;
import ru.stablex.ui.skins.Paint;
import ru.stablex.ui.UIBuilder;
import ru.stablex.ui.widgets.Slider;
/**
* Simple demo project for StablexUI
@RealyUniqueName
RealyUniqueName / Exception.hx
Created November 28, 2013 12:09
Simple exception class with stack information
package fst.exception;
import haxe.CallStack;
/**
* Exceptions base
*
*/
class Exception {
@RealyUniqueName
RealyUniqueName / Base.hx
Last active December 27, 2015 03:59
haxe.macro.MacroType issue
package ;
/**
* Base class
*
*/
class Base{
}//class Base
@RealyUniqueName
RealyUniqueName / Main.hx
Created October 22, 2013 09:36
Actuate fails to call setters of classes which extend classes with type parameters. Affected versions: 1.6.3 - 1.7.0
package;
import flash.display.Shape;
import flash.display.Sprite;
import flash.Lib;
import motion.Actuate;
class Main extends Test<Shape>{
/** this setter is not called on tweening */
package pony.flash;
import haxe.macro.Expr;
import pony.events.Signal;
#if !macro
import flash.external.ExternalInterface;
#end
/**
* ...
* @author AxGord
*/
@RealyUniqueName
RealyUniqueName / Builder.hx
Created July 21, 2013 21:39
Changing base class based on compilation flags
import haxe.macro.Context;
import haxe.macro.Type;
class Builder{
macro static public function getSpriteClass () : Type {
var cls : String = (
Context.defined("custom_base")
? Context.definedValue("custom_base")
: "flash.display.Sprite" //by default use this class