带有模板和枚举的haxe C ++ externs

时间:2018-12-17 17:43:53

标签: c++ haxe extern hxcpp

我一直在努力寻找如何为c ++库创建haxe externs的方法,并且一直试图从themispp的工作中获取一些类,但是我有些困惑。

我将haxelib dev目录链接到themis src目录,以使其更容易添加到@:buildXml,该部分和@:includes似乎可以正常工作,但是我在设置引用c ++的外部设置时遇到了麻烦枚举和模板,所以我想知道最好的方法是什么。

这是我要为其创建外部元素的文件: themis/secure_keygen.hpp

密钥对生成接口:themis wiki

enum asym_algs{EC, RSA};

template <asym_algs alg_t_p>
class themispp::secure_key_pair_generator_t {
     void gen();
     const std::vector<uint8_t>& get_priv();
     const std::vector<uint8_t>& get_pub();  
};

这是我目前的进度:

 @:buildXml("
<files id='haxe'>
  <compilerflag value='-I${haxelib:themis}/src/wrappers/themis/themispp/'/>
    <compilerflag value='-I${haxelib:themis}/src/soter/'/>
    <compilerflag value='-I${haxelib:themis}/src/themis/'/>
</files>
<files id='__lib__'>
  <compilerflag value='-I${haxelib:themis}/src/wrappers/themis/themispp/'/>
    <compilerflag value='-I${haxelib:themis}/src/soter/'/>
    <compilerflag value='-I${haxelib:themis}/src/themis/'/>
</files>
")

@:include("soter_error.h")
@:include("themis_error.h")
@:include("themis.h")
@:include("secure_keygen.hpp")
@:include("secure_rand.hpp")

@:native("themispp::secure_key_pair_generator_t")
extern class SecureKeyPairGeneratorEC
{
    @:native("themispp::secure_key_pair_generator_t<themispp::EC>")
    public static function create():SecureKeyPairGeneratorEC;
}

Main.hx

class Main
{
    static function main()
    {
        SecureKeyPairGeneratorEC.create();
    }
}

试图编译:

-cpp bin/win -cp src -dce no -lib themis -main Main

错误:

Error: Main.cpp
./src/Main.cpp(33): error C2653: 'themispp': is not a class or namespace name
./src/Main.cpp(33): error C2065: 'secure_key_pair_generator_t': undeclared identifier
./src/Main.cpp(33): error C2065: 'EC': undeclared identifier
./src/Main.cpp(33): error C2059: syntax error: ')'
Error: Build failed

Generated Main.cpp

0 个答案:

没有答案