snowkit / hxcpp-guide

A guide for the Haxe CPP target build systems, CFFI and APIs
80 stars 8 forks source link

What about native extensions? #2

Open JeriXNet opened 8 years ago

JeriXNet commented 8 years ago

I've seen google group theme about native extensions formalization over different haxe frameworks or something like that... I just can't find it right now :(

ruby0x1 commented 8 years ago

This repo/guide will be more specific to hxcpp itself, extensions are a bit higher level than that.

There is ongoing work on the above mentioned concepts though, more information about that will be made available soon. It requires a lot of moving parts and to get it done right it takes patience.

ruby0x1 commented 8 years ago

I should note btw, that extensions are typically made up of CFFI bindings, are typically built using the HXCPP build tools - this guide will definitely cover these parts on their own so you can easily understand and create extensions. The specifics about extensions that relate to using them in frameworks is unrelated to the hxcpp guide - is what I meant!

kevinresol commented 7 years ago

I would also like to see some guides about data types conversions between haxe and cpp, more for linc than CFFI.

Info on memory management between haxe/cpp will also be very useful.

ruby0x1 commented 7 years ago

Some of these are a good idea to be have a short guide on!

I will mention again though that they might not be what documented as you might expect. I mentioned in the docs: this guide will not be able to document c++ itself. It is impractical to make a body of work teaching everything you need to know in c++ first. Yet, in order to effectively use a c++ specific interface you must learn about c++ concepts and fundamentals.

It is for this reason that many things can feel undocumented, like there is a lot of "missing pieces", but a large percent of this knowledge doesn't come from hxcpp, it comes from knowing c++, then you can see how the hxcpp things relate.

There are many undocumented things on top of that (in hxcpp usage), which this guide targets. The goal of the guide here is to talk about the behaviour of concepts like these with hxcpp, but without understanding some of the c++ concepts first though, you will probably still feel the same way.

The guide tries to be approachable though, so hopefully it helps a little in both ways!

kevinresol commented 7 years ago

this guide will not be able to document c++ itself

Yeah I understand that. What I really meant is to have some guides on the precautions to be taken when working between c++ and hxcpp. To be more specific, let me rephrase some parts of my last post:

Memory Management: hxcpp is a GC environment, which should we do when passing values/references/pointers to and from hxcpp and plain c++?

How to convert types between hxcpp and c++ or use haxe type directly (or indirectly) in plain c++ (and vice versa)? On haxe side we have Array, String, Dynamic, Anonymous object, Function. On c++ side we have "raw" array (like int[10]), std::array, std::vector, const char*, std::string, struct, etc.