首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pyd wrap_class示例不编译

pyd wrap_class示例不编译
EN

Stack Overflow用户
提问于 2016-03-17 16:32:51
回答 1查看 135关注 0票数 2

我对D相当陌生,并尝试使用pyd框架为我的第一个代码实现一个python包装器。我遵循wrapping.html提供的示例代码,但wrap_class的配方似乎失败了。我的代码片段

代码语言:javascript
复制
import pyd.pyd;
import pyd.class_wrap;

class Foo {
    int m_i;

    this() { m_i = 0; }
    this(int j) { m_i = j; }
    this(int j, int k) { m_i = j + k; }

    int i() { return m_i; }
    void i(int j) { m_i = j; }

    void foo(char[] s) {
        import std.stdio;
        writefln(s, m_i);
    }

    Foo opAdd(Foo rhs) {
        return new Foo(m_i + rhs.m_i);
    }
}


extern(C) void PydMain() {
    module_init();

    // Call wrap_class
    wrap_class!(
        Foo,
        // Wrap the "foo" method
        Def!(Foo.foo),
        // Wrap the "i" property
        Property!(Foo.i),
        // Wrap the constructors.
        Init!(void function(int), void function(int, int))
    );
}

该示例基本上是从该示例中复制出来的,因此无法进行计算,但有以下错误:

代码语言:javascript
复制
/usr/local/lib/python2.7/dist-packages/pyd/infrastructure/pyd/class_wrap.d(526): Error: tuple index 0 exceeds 0
/usr/local/lib/python2.7/dist-packages/pyd/infrastructure/pyd/class_wrap.d(534): Error: template instance pyd.class_wrap.Init!(void function(int), void function(int, int)).Init.Inner!(Foo) error instantiating
/usr/local/lib/python2.7/dist-packages/pyd/infrastructure/pyd/make_wrapper.d(126):        instantiated from here: shim!(2LU, Foo)
/usr/local/lib/python2.7/dist-packages/pyd/infrastructure/pyd/make_wrapper.d(136):        4 recursive instantiations from here: class_decls!(0u, Foo, Def!(foo), Property!(i), Init!(void function(int), void function(int, int)))
/usr/local/lib/python2.7/dist-packages/pyd/infrastructure/pyd/class_wrap.d(1483):        instantiated from here: make_wrapper!(Foo, Def!(foo), Property!(i), Init!(void function(int), void function(int, int)))
/usr/local/lib/python2.7/dist-packages/pyd/infrastructure/pyd/class_wrap.d(1476):        instantiated from here: _wrap_class!(Foo, "Foo", "", "", Def!(foo), Property!(i), Init!(void function(int), void function(int, int)))
pystochcalc.d(35):        instantiated from here: wrap_class!(Foo, Def!(foo), Property!(i), Init!(void function(int), void function(int, int)))
error: command 'dmd' failed with exit status 1

有人知道这条错误信息告诉我什么,以及我如何修复它吗?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-17 17:53:03

dsource的pyd已经过时了。使用GitHub - https://github.com/ariovistus/pyd中的pyd。例如,请检查/examples文件夹。检查/示例/包装中是否有一个示例,该示例演示了如何做这些事情。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36066517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档