nightblade9 / haxesharp Goto Github PK
View Code? Open in Web Editor NEWExtensions for Haxe to make it more accessible to C# developers.
Home Page: https://nightblade9.github.io/haxesharp/
Extensions for Haxe to make it more accessible to C# developers.
Home Page: https://nightblade9.github.io/haxesharp/
Are you open to contributions at this point?
I see that the repo is very active, which is awesome! But, it could also mean that it's young enough that you're not currently accepting contributions, which would also be understandable.
As someone who uses C# professional, but is very interested in Haxe for personal projects, this project is very interesting to me!
Please let me know your thoughts on contributions to this project currently, for those who might be interested in getting involved (like me). Thank you.
Hi @bsinky,
While trying to consume a Dictionary
in one of my games, I ran into an interesting problem where I get a KeyNotFound
exception. Here's a simplified test that reproduces the result:
@Test
public function getGetsValuesSetWithObjectsAsKeys()
{
var m1 = new Monster(7);
var m2 = new Monster(3);
var m3 = new Monster(3);
var m4 = new Monster(3);
var dictionary = new Dictionary<Monster, Int>();
dictionary[m1] = 0;
dictionary[m2] = 0;
dictionary[m3] = 0;
dictionary[m4] = 0;
Assert.that(dictionary[m1], Is.equalTo(0));
Assert.that(dictionary[m2], Is.equalTo(0));
Assert.that(dictionary[m3], Is.equalTo(0));
Assert.that(dictionary[m4], Is.equalTo(0));
}
Helper class:
class Monster
{
private var value:Int;
public function new(value:Int)
{
this.value = value;
}
}
Exception stack:
ERROR: massive.munit.UnhandledException: The given key ({ value => 7 }) was not present in the Dictionary. Keys: { next => #function:0, a => [{ value => 7 },{ value => 3 },{ value => 3 },{ value => 3 }], p => 0, hasNext => #function:0 }
from: haxesharp.exceptions.KeyNotFoundException.new() at 19
Called from /usr/share/haxe/std/haxe/ds/BalancedTree.hx line 146
Called from /usr/share/haxe/std/haxe/ds/BalancedTree.hx line 150
Called from /usr/share/haxe/std/haxe/ds/BalancedTree.hx line 84 at haxesharp.collections.DictionaryTest#getGetsValuesSetWithObjectsAsKeys at haxesharp/collections/Dictionary.hx (41)
at haxesharp/collections/DictionaryTest.hx (186)
at massive/munit/TestRunner.hx (330)
(I also changed the default exception to print out the key and valid key values.)
Is this something you can look into?
No backticks/groups, just a simple "replace everything matching this with some target."
The Haxe timer class does not bring me joy.
This differs from practically every other programming language. Make a better timer please.
As a C# developer, I find the Map
class difficult to use (compiler errors about the Map
sub-type are confusing; checking for specific keys/values is difficult; fetching all values is impossible).
I would like a Dictionary
class that resembles what C# provides.
To support this use-case, at a minimum, we need to implement:
@:arrayAccess
annotation.containsKey(key)
methodcount
propertykeys
property to get all keysvalues
property to get all valuesMap
as a parameter and uses those valuestoMap
method that returns a Map
Later, we can add support for other convenience methods as needed:
add(key, value)
methodclear
methodcontainsValue(value)
methodremove(key)
methodEach method can be individually added (with appropriate unit tests + docs).
Haxe provides a Map
class with three implementations (depending on the key type). Internally, we should store things in a Map
instance. (This also simplifies the constructor and toMap
methods.)
We can pass the type parameters along to the Map
instance constructor, and everything should Just Work.
The only real difficulty is how to efficiently retrieve all the values. We can use two Maps
(one with value => key
mappings) or an array with values, but this effectively doubles the required memory and forces us to keep everything synchronized. If retrieving values is an infrequent operation, it might be okay to just iterate over all keys and retrieve all values in linear time. (We can ship the MVP with this.)
I would approach this by implementing the following:
Dictionary
class in haxesharp.collections
with a constructor and array-access to get/set valuesMap
that Haxe abstracts over:
string
keysint
keysenum
values for keysOnce that's done, the rest of the methods should be easy to selectively implement.
@bsinky is this something you would like to work on?
Used in Eman Adventures, battle state. Right now, using .first
instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.