Skip to content

Instantly share code, notes, and snippets.

@pidpawel
Created June 13, 2014 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pidpawel/b32a2b2a412445a54b21 to your computer and use it in GitHub Desktop.
Save pidpawel/b32a2b2a412445a54b21 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
from cffi import FFI
f = FFI()
@f.callback("int(int)")
def pytest(a):
return a*a
f.cdef("""
void test(void);
int (*pytest)(int);
""")
l = f.verify('''
#include <stdio.h>
static int (*pytest)(int);
void test(){
printf("Alice ma %d lalek.\\n", pytest(3));
}
''')
l.pytest = pytest
l.test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment