-
Notifications
You must be signed in to change notification settings - Fork 63
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
overriding standard types #42
Comments
Bytes implementation 72d7b83 |
Oh, and thanks to @andyli and Travis CI we can see that |
I didn't get yet whay @coreapi does :)
|
@eduardo-costa it checks whether all fields are defined correctly in the overriden std class. it's used in haxe std for providing target implementations. it does check field existance, type, access modifiers, method signatures, etc. |
Got it! Thanks!
|
Yes I'm aware of the issue with Bytes redefinition. I actually opened HaxeFoundation/haxe#4249 because of that. Not sure if that's the right solution or not. I actually thing we need to find better ways for libraries to override/implement some std classes as well as configure which implementation is used depending on the compiled platform (in a safe manner, ie like we do for |
I wish we implemented the |
This currently breaks haxe.io.BytesBuffer compilation, and breaks some WebGL code I'm having in Node Webkit as well (since I need to have Bytes that maps to JS ArrayBuffer). Should we not drop the haxe.io.Bytes <-> NodeBuffer support since it seems recent NodeJS version does uses ArrayBuffer ? (I didn't test the later) |
Up again : should we remove this and instead add NodeBuffer <-> Bytes conversion (in NodeBuffer class) since they are both based on ArrayBuffer but uses different APIs ? |
To be honest, I'd remove anything but node.js externs (to reduce scope of this particular lib), and then make a separate lib that provides sys stuff. |
@nadako +1 |
Maybe, but that just moves the problem away, no ? But looking at the Buffer API it seems there's no way to easy convert from/to ArrayBuffer (with no copying being done in the process). I don't then understand why they say that in 4.0+, Buffer is backed by UInt8Array. Unless there's a trick, can Node users confirm this ? If there's no easy way, I agree we should move it out of hxnodejs for now, until we come up with a solution. |
Looking at this code: https://github.com/nodejs/node/blob/master/lib/buffer.js#L43-L62, it seems that Buffer actually IS Uint8Array |
Oh. then that makes things easy, right ? |
I don't know, will have to look into it? What's the decision anyway? Support 4.0+ and provide only |
What I'm proposing (open for discuss):
|
Sounds sane, I'll try to find time to look into it today. |
BTW it might be possible to have the node Buffer be a reference to an ArrayBuffer (with memory sharing) if created by passing an ArrayBuffer, to confirm by experiment, see |
(passing an UInt8Array for instance will create a copy) |
…+, Buffer is actually a Uint8Array on steroids. Add helper methods to convert Buffer to/from haxe.io.Bytes. Use them for sys.io.File See #42
Okay, I removed haxe.io stuff and added conversion helper methods. Please review. |
We have a problem with Haxe 3.2.0 however: the |
Also, can we get rid of js.html.compat stuff for nodejs somehow? |
@nadako +1 to keep hxnodejs extern-only |
I did that, pls review! |
Looks good to me |
ok, everything seems good to me! Also, we need to decide on the name. We can have the library named either "nodejs" or "hxnodejs", as soon as we have a proper |
I'm good! 2015-11-03 18:18 GMT-02:00 Nicolas Cannasse [email protected]:
[image: Imagem inline 1] |
Because any Buffer usage right now outputs a ton of unused compat stuff in the output js. |
@nadako Sorry, I've let this pass. Can you not simply #if !nodejs it ? |
You can have http://lib.haxe.org/p/nodejs! |
Okay, I added |
hxnodejs seems consistent with hxjava, hxcs, hxcpp, but only if it includes the sys stuff? |
Honestly, I'm okay with any name. |
what if we name it hxnodejs and confine its scope as node extern + haxe std library? |
We have hxnodelibs for that..
|
@kevinresol +1 If there'll be no further discussion, I can make a haxelib release. |
@nadako One question: Does the JS output runs equally fine on browsers when |
Oh, I gotta read that... |
So, that topic seems to be Haxe-related which means it shouldn't block release of hxnodejs. @ncannasse waiting for you to say the word. |
I'll close this issue, as we really should use #40 for release discussion. The |
Actually, let's leave this open for now, since the general issue is still there. Maybe it should go to Haxe's issues? |
hxnodejs is ok for me. Let's release! (unless there's something else to discuss before that?) |
@nadako The issue with the type collision can be solved by making two implementations in |
I tried to add
haxe.io.Bytes
implementation, but there's a problem that in a macro it also tries to use the overriden class and then complains about usingjs.node.Buffer
in a macro context.What can we do with that? One option is to just move nodejs sys stuff into Haxe itself (and fence with
#if nodejs
), another one is to make it possible to override types only for target output context, not the macro one.Also,
@:coreApi
metadata doesn't work on our overriden types.cc @Simn @ncannasse
The text was updated successfully, but these errors were encountered: