dropecho.interop

A haxe library with interop / utils used by other dropecho libs.
https://github.com/dropecho/interop/

To install, run:

haxelib install dropecho.interop 0.9.3 

See using Haxelib in Haxelib documentation for more information.

README.md

A haxe library with utils used by other dropecho libs.

Mostly for internal use.

This libary contains "abstract" classes that allow easier interop with native code for dropecho libraries.

For example:

AbstractArray

in C# acts as a List. in JS acts as a native array.

AbstractIterable

in C# acts as an IEnumerable (accepts List, arrays, HashSet, LINQ queries, ...). in JS acts as a haxe Iterable.

AbstractMap

in C# acts as a native dictionary. in JS the shape depends on the key type, picked while compiling:

Key typeJS shape
Stringplain object (ref by obj[key])
Int, Floatplain object; keys come back as numbers when iterated
enumHaxe EnumValueMap; keys compare by value
class, anonymous object, Boolnative Map; objects compare by identity, like C#
a type parameterplain object; keys come back as strings when iterated

AbstractSet

A set of unique items. Pass a key function to decide which items are equal:

var seen = new AbstractSet<String>();
var tiles = new AbstractSet<Tile>(t -> t.y * width + t.x); // same position = same tile

in C# acts as a native HashSet (a key function becomes its comparer). in JS is a small wrapper, picked while compiling from the item type:

Item typeJS backingEqual when
String, numbers, Boolnative Mapsame value
class, anonymous objectnative Mapsame object
enumHaxe EnumValueMapsame value, e.g. Floor(1)
any, with a key functioneithersame key

AbstractFunc

in C# will convert to action_X or func_X where X is # of inputs/type params. in JS is a function.

In C#, a Haxe function passed as a Func_N/Action_N becomes a delegate that calls it with typed arguments. Turning that delegate back into a Haxe function gives back the original function.

Add -D dropecho-interop-unboxed to also pass Int/Float arguments and results without boxing, which makes numeric calls about 2–5x faster. It relies on internals of the Haxe C# target, so it's off by default.

Contributors
vantreeseba
Version
0.9.3
Published
2 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂