默认方法参数不

2024-09-29 01:31:23 发布

您现在位置:Python中文网/ 问答频道 /正文

Cython似乎没有意识到,sf::RenderTarget.clear()方法可以用不同的参数调用,并且只允许调用.pxd中最后声明的变量。在

SFML的头文件(source):

class RenderTarget {
    void clear(const Color& color = Color(0, 0, 0, 255));
}

我的Cython.pxd:

^{pr2}$

我的Cython包装:

^{3}$

编译错误:Call with wrong number of arguments (expected 1, got 0)

所以我只能调用whe .clear(color)变量,而不能调用带有默认参数.clear()的变量。我做错什么了?在

我的实现试图遵循explained here,但是我不能让它工作。在


Tags: 方法声明source参数头文件sfcythonclass
1条回答
网友
1楼 · 发布于 2024-09-29 01:31:23

我已经为类似情况下的方法提供了别名(C names)。在这种情况下

cdef extern from 'SFML/Graphics.hpp' namespace 'sf' nogil:
    cppclass CRenderTarget 'sf::RenderTarget':
        void clear0 "clear" ()

相关问题 更多 >