Giter Club home page Giter Club logo

Comments (8)

kevinresol avatar kevinresol commented on July 24, 2024

This is already elaborated in the Goals > Data Type section.

from napi.

Lotes avatar Lotes commented on July 24, 2024

Ok, my problem was not the goal or target... it was about understanding Haxe, the source.
Haxe implements its own data structures, instead of reusing existing native solutions.
Now I understand, my mistake.

Then... how can this be done? Let's use the HashMap data type. In C# it is equal to IDictionary. Say you want to pass a list of named objects to a function. How do you write down the signature of this function in Haxe? In C# it has to result in "void func(IDictionary input)". Is that makeable in Haxe? Using a wrapper, you will have to pack your input dictionary first into the Wrapper type.

from napi.

Lotes avatar Lotes commented on July 24, 2024

Another issue are exceptions. If you wrap a native class, you also have to wrap the exception.
Errors have to be reproducible for each target language.

Other thought: A macro in combination with metadata could be used to replace the proxy types with native types.

from napi.

kevinresol avatar kevinresol commented on July 24, 2024

There is a "code" branch in this repo containing some PoC code, it should demonstrate some solutions to your questions.

from napi.

kevinresol avatar kevinresol commented on July 24, 2024

The basic idea is to wrap Haxe's data type with native type. So that Haxe devs (library authors) handle haxe types and native devs (library users) handle native types.

from napi.

Lotes avatar Lotes commented on July 24, 2024

You MUST write new data structures to ensure that behaviour is the same on all targets. That is already done by the Haxe team. If you want a native interface for the user, you also will have a native behaviour, which can differ from other target implementations. You could use an adapter to pack a dictionary into a hash map for inputs. Or for outputs you need to unpack your hashmap.

from napi.

kevinresol avatar kevinresol commented on July 24, 2024

In no way i must do something :)

from napi.

Lotes avatar Lotes commented on July 24, 2024

I want to help. I am just thinking a bit too loud. Of course you do not have to do anything.
I do not understand every trick in Haxe. I am reading your code, but it is hard to understand right now.

from napi.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.