Created
October 31, 2010 13:24
-
-
Save taichi/656581 to your computer and use it in GitHub Desktop.
cython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* callback.h START*/ | |
#ifndef _CALLBACK_H_ | |
#define _CALLBACK_H_ | |
typedef int (*op)(int,int); | |
int binary_op(int a, int b, op func); | |
#endif | |
/* callback.h END*/ | |
/* callback.c START */ | |
#include "callback.h" | |
int binary_op(int a, int b, op func) { | |
return (func)(a,b); | |
} | |
/* callback.c END */ | |
/* cython2.pyx START */ | |
cdef extern from "callback.h": | |
ctypedef int (*op)(int,int) | |
int binary_op(int a, int b, op func) | |
cdef int callback(int a, int b): | |
return bop_callback(a,b) | |
cdef bop_callback | |
def bop(a,b,func): | |
global bop_callback | |
bop_callback = func | |
print(bop_callback(a,b)) | |
print('aaaa') | |
return binary_op(a,b,callback) | |
/* cython2.pyx END */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment