我有一个A.pxd(只是声明函数)和A.pyx只包含一个带有所有函数体的A类.
比我有B继承自A,
对于BI而言,B.pxd具有一些功能
B.pyx
class Bclass(A):
#all the funcions body
Run Code Online (Sandbox Code Playgroud)
我现在想告诉B.pyx如何将A识别为类型名称?
我做的是:
B.pyx
cimport A
import A
from A import Aclass
cdef Bclass(Aclass):
#body
Run Code Online (Sandbox Code Playgroud)
但它告诉我:A不是类型名称
如果我只在一个file.pyx中执行此操作它没有问题,但使用files.pxd它不会.
我有一个private.h,public.h而且file.c,我需要将它包装到Cython中.如何包装功能Person_ptr Person_create(const char* name);?
private.h:
#ifndef __PERSON_PRIVATE_H__
#define __PERSON_PRIVATE_H__
#include "Person.h"
typedef struct Person_TAG {
char* name;
int age;
} Person;
void person_init(Person_ptr self, const char* name);
# endif /* __PERSON_PRIVATE_H__ */
Run Code Online (Sandbox Code Playgroud)
public.h
#ifndef __PERSON_H__
#define __PERSON_H__
#include <assert.h>
typedef struct Person_TAG* Person_ptr;
#define PERSON(x) \
((Person_ptr) (x))
#define PERSON_CHECK_INSTANCE(x) \
assert(PERSON(x) != PERSON(NULL))
/* public interface */
Person_ptr Person_create(const char* name);
void Person_destroy(Person_ptr self);
const char* Person_get_name(const Person_ptr self); …Run Code Online (Sandbox Code Playgroud)