-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More types #3
Comments
Thanks a lot for making Ammer <3 I was wondering how to deal with other types in an efficient way. |
@melMass Good point! An efficient way to pass a vector/contiguous array of primitives across the FFI sounds useful. The problem is that not all targets will actually have a way to represent this efficiently, so there may be some copying to deal with this … Fortunately, both HashLink and hxcpp have an efficient runtime representation. I'm also interested in more details about your intended application for this, if you are willing to share! I assume this is for a math or ML library? |
I'm personally mainly interested in those targets, to be honest :) Edit: Your answer raised another question, sorry, do you plan to support more targets with Ammer? Is it even possible? |
@melMass I didn't see your edit until now! Yes, more targets are in the works. For now I just have #2 open for supporting Lua (when running with LuaJIT). I am reasonably certain all Haxe sys targets could theoretically support ammer. Some would probably be more painful to support than others. Feel free to open an issue for a particular target if you have a use case. |
By any chance are you still interested by the idea of adding vector types ? |
@melMass Well, neither this issue nor this project is abandoned, though I have not had much free time to work on it. When I do, reorganising the types will be one of the top priorities. If you want to experiment in the meanwhile: you might get lucky and get away with unsafe casts between |
Thanks for the answer, it's good to know that Ammer is still alive. |
I just saw your presentation (maybe you should link it in the readme it's very interesting). Congrats on the documentation aswel!!! |
Would like to add native enum to the list too |
@kevinresol Yes, I had issues with trying to make enums work like Haxe enums consistently on all targets… For now you can just model individual enum cases with static variables. class SomeLIbrary extends ammer.Library<"foo"> {
public static var SOME_ENUM_CASE:Int;
} |
What if a library function returns a native enum? ok nvm, I missed the fact that enum is already in the TODO list. |
@kevinresol Yes, I added that after your first comment. If a library function returns a native enum, it's fine in C, where it is just an integer. So the method can be defined with an |
In yoga there is a enum YGValue {
Undefined;
Auto;
Point(v:Single);
Percent(v:Single);
} while its native representation is: typedef struct YGValue {
float value;
YGUnit unit; // enum YGUnit {...}
} YGValue; Are there any tricks so that I can write custom glue code to support it? |
Yeah, that looks almost like an ADT. At the moment that is not mappable to an enum for sure (without writing your own mapping). I'll have to think about this a bit more. There is a similar pattern in SDL, with its events (event type + union of event data types). |
Haxe side:
Void
enum
s though)Native side:
int32
float
(rather thandouble
)struct
s - Haxe won't do struct passing in general but we can construct astruct
at the callsite from the object; may not be very performantVector<Float>
in HaxeThe text was updated successfully, but these errors were encountered: