Haxe会创建图书馆吗? [英] Would Haxe work for creating libraries?

查看:71
本文介绍了Haxe会创建图书馆吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在考虑使用Haxe的跨语言功能,但不确定是否最适合此任务.我将编写一个通用库,该库应该能够在目标语言中使用并被记录(能够应用诸如doxygen之类的东西).换句话说,我想用Haxe编写一个泛型库,输出c ++代码(完成后输出java),并让其他程序员可以访问它(不仅对C +编译器可读),这是吗?这项任务的最佳选择,或者只是为每种语言编写一个版本的库会更好吗?

解决方案

即使选择的平台可能有些尴尬,也可以.

在JavaScript,neko和Flash上​​,生成的代码与本机代码非常接近,人们甚至在不知道它是在Haxe中生成代码的情况下也可以使用它.

在PHP上,恐怕我不太清楚它是如何工作的.但是有一些名称空间的技巧有些笨拙,但我认为可以通过用手写代码包装库来解决.

在C ++上,如果您不介意使用一些简单的代码来启用反射功能,那么它几乎可以正常工作.它具有处理构造函数的非标准方式,并且您还应该非常小心,因为它附带有gc,而且我不知道它处理不知道的外部代码保存引用的程度如何.

关于新目标-C#和Java将与本机代码100%互操作.除委托外,大多数Haxe功能都映射到平台的本机功能中.但是,如果您不在界面中公开委托,那很好.他们还将生成一些样板代码,以在这些平台上实现快速反射,但是如果您知道自己在做什么,将有多种方法可以禁用此功能.

I was thinking of using Haxe for it's cross-language ability, but wasn't sure if it was the best for this task. I'm going to write a generic library that should be able to be used in the target languages and be documented(able to apply something like doxygen.). To put it another way, I'd like to write a generic library in Haxe, output c++ code(and java once it done) , and have it accessible to other programmers.(readable to more than just the C+ compiler) Is this the best choice for this task, or would it be better if I just wrote a version of the library for each language?

解决方案

Sure it's possible, even though there might be some awkwardness depending on the chosen platform.

On JavaScript, neko and Flash, the generated code is very close to native ones, and people will be able to use it without even knowing it was generated in Haxe.

On PHP, I'm afraid I don't know very well how it works. But there is some namespace hacks that are a little awkward, but I think these could be solved by wrapping the library with hand written code.

On C++, if you don't mind with a little boilerplate code to enable reflection to work, it will work mostly alright. It has a nonstandard way of dealing with constructors, and also you should be very careful since it has a gc attached to it, and I don't know how well it handles having external code holding references it isn't aware of.

About the new targets - C# and Java will interoperate 100% with native code. Most Haxe features are mapped into the platforms' native capabilities, with the exception of delegates. But if you don't expose delegates in your interface, it's fine. They will also generate some boilerplate code as well to enable fast reflection on those platforms, but there will be ways to disable this if you know what you're doing.

这篇关于Haxe会创建图书馆吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆